public IHttpActionResult UpdateUser(int id, UserEditDo userDo) { User user = dbContextAccessor.DbContext.Set <User>() .SingleOrDefault(e => e.UserId == id); user.Modify(userDo.Fullname, userDo.Email); if (!string.IsNullOrEmpty(userDo.NewPassword)) { user.ChangePassword(userDo.OldPassword, userDo.NewPassword); } unitOfWork.Save(); return(Ok()); }
public IHttpActionResult GetUserProfile() { User user = dbContextAccessor.DbContext.Set <User>() .SingleOrDefault(e => e.UserId == this.userContext.UserId); UserEditDo returnValue = new UserEditDo() { UserId = user.UserId, Username = user.Username, Fullname = user.Fullname, Email = user.Email, IsActive = user.IsActive }; return(Ok(returnValue)); }