public ActionResult Delete(int id) { var ctx = new ByteShopDbContext(); var entity = ctx.Entities.FirstOrDefault(e => e.Id == id); if (entity != null) { ctx.Entities.Remove(entity); } ctx.SaveChanges(); return(Json(new { Status = "OK" })); }
public ActionResult Create(string description) { var ctx = new ByteShopDbContext(); var e = ctx.Entities.Add(new Entity { Description = description }); ctx.SaveChanges(); return(Json(new EntityViewModel { Id = e.Id, Description = e.Description })); }