using EasyBL.WebApi.Filters;
using EasyBL.WEBAPP;
using EasyBL.WEBAPP.SYS;
using Entity.ShowEasyDtos;
using Entity.Sugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web;
using System.Web.Http;
namespace WebApp.Controllers
{
public class MembersController : ApiController
{
[HttpPost]
//[SEApiSecurityFilter]
public HttpResponseMessage Login([FromBody] Login dto)
{
//登陸並返回token
return new MembersService().Login(dto);
}
[HttpPost]
[SEApiSecurityFilter]
public HttpResponseMessage Member([FromBody] MemberDTO Member)
{
var SEToken = SETokenUtil.GetToken(this.Request);
Member.Account = SEToken.Account;
return new MembersService().Update(Member);
}
///
/// 上傳文件
///
///
///
[HttpPost]
public HttpResponseMessage UploadAvatar()
{
return new MembersService().UploadAvatar();
}
//註銷帳號
[HttpGet]
[SEApiSecurityFilter]
public HttpResponseMessage DeactivateAccount()
{
var SEToken = SETokenUtil.GetToken(this.Request);
return new MembersService().DeactivateAccount(SEToken.OrgID, SEToken.Account);
}
//會員個人訊息查詢
[HttpGet]
[SEApiSecurityFilter]
public HttpResponseMessage Info()
{
//根據參數取得Member的詳細信息,調用時需要在Header中添加token相關信息,包括orgId,userid,timestamp,token
//需要驗證的token相關信息的Api,添加上 [SEApiSecurityFilter]即可
var SEToken = SETokenUtil.GetToken(this.Request);
return new MembersService().GetMemberInfo(SEToken.OrgID, SEToken.Account);
}
//重設密碼
[HttpPost]
[SEApiSecurityFilter]
public HttpResponseMessage ResetNewPassword(string Password)
{
var SEToken = SETokenUtil.GetToken(this.Request);
return new MembersService().ResetNewPassword(SEToken.OrgID, SEToken.Account, Password);
}
[HttpGet]
[SEApiSecurityFilter]
public HttpResponseMessage Contacts()
{
var SEToken = SETokenUtil.GetToken(this.Request);
return new ContactService().GetContacts(SEToken.OrgID, SEToken.Account);
}
[HttpPost]
[SEApiSecurityFilter]
public HttpResponseMessage Contact([FromBody] SETB_CRM_Contact Contact)
{
var SEToken = SETokenUtil.GetToken(this.Request);
Contact.Account = SEToken.Account;
Contact.OrgID = SEToken.OrgID;
return new ContactService().SaveContact(Contact);
}
[HttpPost]
[SEApiSecurityFilter]
public HttpResponseMessage Contact(string ContactID)
{
var SEToken = SETokenUtil.GetToken(this.Request);
var Contact = new SETB_CRM_Contact();
Contact.ContactID = ContactID;
Contact.Account = SEToken.Account;
Contact.OrgID = SEToken.OrgID;
return new ContactService().RemoveContact(Contact);
}
[HttpGet]
[SEApiSecurityFilter]
public HttpResponseMessage Companies(string Lang)
{
var SEToken = SETokenUtil.GetToken(this.Request);
return new CompanyService().GetCompanies(SEToken.Account, Lang);
}
[HttpPost]
[SEApiSecurityFilter]
public HttpResponseMessage Company([FromBody] SETB_CRM_Company Company)
{
var SEToken = SETokenUtil.GetToken(this.Request);
Company.Account = SEToken.Account;
return new CompanyService().SaveCompany(Company);
}
[HttpPost]
[SEApiSecurityFilter]
public HttpResponseMessage Company(string CompanyID)
{
var SEToken = SETokenUtil.GetToken(this.Request);
var Company = new SETB_CRM_Company();
Company.CompanyID = CompanyID;
Company.Account = SEToken.Account;
return new CompanyService().RemoveCompany(Company);
}
}
}