public async Task <IHttpActionResult> UpdateChipTypes(int id, [FromBody] SidChipType entity) { SidChipType existingEntity = await context.SidChipTypes.FindAsync(entity.Id); if (entity == null) { return(NotFound()); } if (id != entity.Id) { return(BadRequest(ModelState)); } if (entity == null) { return(BadRequest(ModelState)); } if (existingEntity != null && context.Entry(existingEntity).State != EntityState.Detached) { context.Entry(existingEntity).State = EntityState.Detached; } //Overide entity if exist context.SidChipTypes.Attach(entity); context.Entry(entity).State = EntityState.Modified; await context.SaveChangesAsync(); return(Ok <SidChipType>(entity)); }
public async Task <IHttpActionResult> CreateChipType(SidChipType entity) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } context.SidChipTypes.Add(entity); await context.SaveChangesAsync(); return(Ok <SidChipType>(entity)); }