public string Binding()
        {
            GridRequestParameters param = GridRequestParameters.Current;

            List <Context.SalesOrder>    items     = RepoSalesOrder.FindAllKonsolidasi();
            List <SalesOrderKonsolidasi> ListModel = new List <SalesOrderKonsolidasi>();

            foreach (Context.SalesOrder item in items)
            {
                SalesOrderKonsolidasi newItem = (new SalesOrderKonsolidasi(item));
                newItem.NamaCustomer = RepoLookupCode.FindByPK(newItem.CustomerId).Nama;
                newItem.KodeNama     = RepoCustomer.FindByPK(newItem.SupplierId.Value).CustomerCodeOld;
                newItem.SupplierName = RepoCustomer.FindByPK(newItem.SupplierId.Value).CustomerNama;
                ListModel.Add(newItem);
            }

            int total = RepoSalesOrder.CountKonsolidasi(param.Filters);

            return(new JavaScriptSerializer().Serialize(new { total = total, data = ListModel }));
        }
        public JsonResult Delete(int id)
        {
            bool isExistData = false;

            ResponeModel response = new ResponeModel(true);

            Context.DaftarHargaKonsolidasi dbItem = RepoDHKonsolidasi.FindByPK(id);
            List <int> listId = dbItem.DaftarHargaKonsolidasiItem.Where(i => i.IdDaftarHargaKonsolidasi == dbItem.Id).Select(i => i.Id).ToList();

            isExistData = RepoSalesOrder.FindAllKonsolidasi().Where(a => listId.Contains(a.SalesOrderKonsolidasi.IdDaftarHargaItem.Value)).Count() > 0;

            if (!isExistData)
            {
                RepoDHKonsolidasi.delete(dbItem, UserPrincipal.id);
            }
            else
            {
                response.Success = false;
                response.Message = "Data sudah digunakan, Penghapusan gagal";
            }

            return(Json(response));
        }