public bool EditLeader(LeaderEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx.Leaders.FirstOrDefault(p => p.LeaderID == model.LeaderID); entity.LeaderName = model.LeaderName; return(ctx.SaveChanges() == 1); } }
public IHttpActionResult Put(LeaderEdit leader) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = new LeaderService(); if (!service.EditLeader(leader)) { return(InternalServerError()); } return(Ok()); }