public IHttpActionResult Create(NeedType needType) { if (!ModelState.IsValid) { return BadRequest(ModelState); } Context.NeedTypes.Add(needType); Context.SaveChanges(); return Ok(); }
public IHttpActionResult Update(int id, NeedType needType) { needType.Id = id; if (!ModelState.IsValid) { return BadRequest(ModelState); } Context.NeedTypes.Attach(needType); var entry = Context.Entry(needType); entry.State = EntityState.Modified; Context.SaveChanges(); return Ok(); }