public bool UpdateTalent(TalentEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Talents .Single(e => e.TalentId == model.TalentId && e.UserId == _userId); entity.TalentTitle = model.TalentTitle; entity.TalentDescription = model.TalentDescription; return(ctx.SaveChanges() == 1); } }
// Put (update) -- take note we'll for sure have to update the time availability as a matter of basic function public IHttpActionResult Put(TalentEdit talent) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateTalentService(); if (!service.UpdateTalent(talent)) { return(InternalServerError()); } return(Ok()); }