public ActionResult Destroy([DataSourceRequest]DataSourceRequest request, GridCategoryViewModel model) { var categoryEntity = this.Data.Categories .All() .Include("Tickets") .Include("Tickets.Comments") .FirstOrDefault(x => x.Id == model.Id); if (categoryEntity != null) { foreach (var ticket in categoryEntity.Tickets.ToList()) { foreach (var comment in ticket.Comments.ToList()) { this.Data.Comments.Delete(comment); } this.Data.Tickets.Delete(ticket); } } this.Data.Categories.Delete(categoryEntity); this.Data.SaveChanges(); return this.GridOperation(request, model); }
public ActionResult Update([DataSourceRequest]DataSourceRequest request, GridCategoryViewModel model) { var categoryEntity = this.GetById(model.Id) as Category; this.BaseUpdate(model.GetEntityModel(categoryEntity)); return this.GridOperation(request, model); }
public ActionResult Create([DataSourceRequest]DataSourceRequest request, GridCategoryViewModel model) { var categoryEntity = model.GetEntityModel(); model.Id = (int)this.BaseCreate(categoryEntity); return this.GridOperation(request, model); }