public JsonResult Delete(int id) { bool isExistData = false; ResponeModel response = new ResponeModel(true); Context.DaftarHargaOnCall dbItem = RepoDHO.FindByPK(id); List <int> listId = dbItem.DaftarHargaOnCallItem.Where(i => i.IdDaftarHargaOnCall == dbItem.Id).Select(i => i.Id).ToList(); isExistData = RepoSO.FindAllOnCall().Where(a => listId.Contains(a.SalesOrderOncall.IdDaftarHargaItem.Value)).Count() > 0; if (!isExistData) { RepoDHO.delete(dbItem); } else { response.Success = false; response.Message = "Data sudah digunakan, Penghapusan gagal"; } return(Json(response)); }
public string Binding() { GridRequestParameters param = GridRequestParameters.Current; //List<Context.SalesOrder> items = RepoSalesOrder.FindAllOnCall(param.Skip, param.Take, (param.Sortings != null ? param.Sortings.ToList() : null), param.Filters); List <Context.SalesOrder> items = RepoSalesOrder.FindAllOnCall(); items = items.Where(d => d.Status.ToLower() == "draft").ToList(); List <SalesOrderOncall> ListModel = new List <SalesOrderOncall>(); foreach (Context.SalesOrder item in items) { var _model = new SalesOrderOncall(item); _model.ListLoad.Clear(); _model.ListUnload.Clear(); ListModel.Add(_model); } int total = RepoSalesOrder.CountOncall(param.Filters); return(new JavaScriptSerializer().Serialize(new { total = ListModel.Count(), data = ListModel })); }