public async Task <IActionResult> UpdateInformation([FromBody] UpdateUserInformationDataModel userInfo) { if (ModelState.IsValid) { try { var userID = HttpContext.User.Identity.Name; if (userID == null) { return(StatusCode(StatusCodes.Status401Unauthorized)); } ApplicationUser user = await _context.Set <ApplicationUser>().SingleOrDefaultAsync(item => item.UserName == userID); Account account = _context.Set <Account>().FirstOrDefault(x => x.ID == user.AccountID); if (user == null || account == null) { return(null); } var result = await _usersService.UpdateUserInformation(userID, userInfo); if ((bool?)result == true) { return(Ok()); } else { return(BadRequest("Faild in save data")); } } catch (Exception ex) { return(BadRequest(ex.Message)); } } return(BadRequest("Invaild information please check the sent information and try again")); }
[HttpGet, AuthorizeToken] public async Task <IActionResult> UpdateInformation([FromBody] UpdateUserInformationDataModel userInfo) { return(RedirectToAction("UpdateInformation", "Users", userInfo)); }