public bool UpdateInstClassification(InstrumentClassificationEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Classifications .Single(e => e.ClassificationId == model.ClassificationId); entity.TypeOfCategory = model.TypeOfCategory; entity.TypeOfInstrument = model.TypeOfInstrument; return(ctx.SaveChanges() == 1); } }
public IHttpActionResult Put(InstrumentClassificationEdit classification) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateClassificationService(); if (!service.UpdateInstClassification(classification)) { return(InternalServerError()); } return(Ok()); }