public OutAccountVM SignUp(InAccountVM account) { var hasBeenSignUp = db.Accounts.SingleOrDefault(x => x.Email == account.Email && x.LoginBy == account.LoginBy); var result = new OutAccountVM(); if (hasBeenSignUp != null) { result.StatusCode = StatusCodes.Status500InternalServerError; return(result); } var value = new Accounts() { AccountId = Guid.NewGuid(), BirthDay = account.BirthDay, Email = account.Email, LoginBy = account.LoginBy, Password = AccountHelper.EncodePassword(account.Password) ?? "", RoleId = db.Roles.FirstOrDefault(x => x.RoleName == "一般使用者").RoleId, UserName = account.UserName }; db.Accounts.Add(value); db.SaveChanges(); result.StatusCode = StatusCodes.Status200OK; return(result); }
public void UpdateAccount(InAccountVM inAccountVM) { var value = db.Accounts.FirstOrDefault(x => x.AccountId == inAccountVM.AccountID); value.UserName = inAccountVM.UserName; value.Phone = inAccountVM.Phone; value.BirthDay = inAccountVM.BirthDay; value.Gender = inAccountVM.Gender; value.Subscribe = inAccountVM.Subscribe; db.SaveChanges(); }
public OutAccountVM Login(InAccountVM account) { var result = new OutAccountVM(); var value = db.Accounts.Where(x => x.LoginBy == account.LoginBy) .SingleOrDefault(x => x.Email == account.Email && x.Password == AccountHelper.EncodePassword(account.Password)); if (value != null) { result.StatusCode = StatusCodes.Status200OK; result.AccountID = value.AccountId; result.Email = value.Email; result.Name = value.UserName; } else { result.StatusCode = StatusCodes.Status500InternalServerError; } return(result); }
public void UpadateAccount(InAccountVM inAccountVM) { accountService.UpdateAccount(inAccountVM); }
public OutAccountVM Login(InAccountVM inAccountVM) { return(accountService.Login(inAccountVM, jwtHelper)); }
public OutAccountVM SignUp(InAccountVM inAccountVM) { return(accountService.SignUp(inAccountVM)); }