private void Update(EquipmentViewModel model) { var equipment = entities.Equipments.FirstOrDefault(x => x.ID == model.ID); equipment = Utility.Utility.ToEquipment(model, equipment); entities.Entry(equipment).State = System.Data.Entity.EntityState.Modified; entities.SaveChanges(); }
public IHttpActionResult DeleteEquipment(string id) { if (!ModelState.IsValid) { return(BadRequest("invalid request")); } using (var context = new EquipmentEntities()) { var equip = context.EQUIPMENTs.Where(s => s.ID == id).FirstOrDefault(); if (equip == null) { return(NotFound()); } context.Entry(equip).State = System.Data.Entity.EntityState.Deleted; context.SaveChanges(); return(Ok()); } }