public async Task <IHttpActionResult> SetClientData(ClientProfileBindingModel model) { try { string id = RequestContext.Principal.Identity.GetUserId(); var result = await UserManager.SetTwoFactorEnabledAsync(id, model.TwoFactorEnabled); if (!result.Succeeded) { return(BadRequest()); } Customer customer = await db.Customers.FindAsync(id); customer.Name = model.Name; customer.Surname = model.Surname; customer.Email = model.Email; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomerExists(id)) { return(NotFound()); } else { throw; } } return(Ok("OK")); } catch (Exception exception) { return(BadRequest(exception.Message)); } }
public async Task <IHttpActionResult> GetClientData() { string id = RequestContext.Principal.Identity.GetUserId(); Customer customer = await db.Customers.FindAsync(id); var user = await UserManager.FindByNameAsync(User.Identity.Name); if (customer == null || user == null) { return(NotFound()); } ClientProfileBindingModel profile = new ClientProfileBindingModel { Name = customer.Name, Surname = customer.Surname, Email = customer.Email, TwoFactorEnabled = user.TwoFactorEnabled }; return(Ok(profile)); }