public IHttpActionResult PutLeader(int id, DTO.Leader vm) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != vm.Id) { return(BadRequest()); } var email = _db.Leaders.AsNoTracking().Single(x => x.Id == vm.Id).Email; var model = vm.ToModel(); _db.Entry(model).State = EntityState.Modified; var user = UserManager.FindByEmail(email); user.UserName = vm.Email; user.Email = vm.Email; user.LockoutEnabled = false; try { UserManager.Update(user); _db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!LeaderExists(id)) { return(NotFound()); } throw; } return(StatusCode(HttpStatusCode.NoContent)); }
public static Models.Leader ToModel(this DTO.Leader src) { return(Mapper.Map <Models.Leader>(src)); }