public int sppUpdateBatch(List <spp> sppList) { //spp sppRequest = new spp(); //spp sppFound = new spp(); //string[] sppListRequest = (string[])convertJsonToType(sppListRequestJson, typeof(string[])); foreach (spp sppData in sppList) { //sppRequest = sppRequestJson; spp sppFound = mspbu.spps.Find(sppData.Id); if (sppFound != null) { sppFound.name = (sppData.name != null) ? sppData.name : sppFound.name; sppFound.address = (sppData.address != null) ? sppData.address : sppFound.address; sppFound.police_no = (sppData.police_no != null) ? sppData.police_no : sppFound.police_no; sppFound.shipment_no = (sppData.shipment_no != null) ? sppData.shipment_no : sppFound.shipment_no; sppFound.volume = (sppData.volume != null) ? sppData.volume : sppFound.volume; sppFound.dens_temp = (sppData.dens_temp != null) ? sppData.dens_temp : sppFound.dens_temp; sppFound.buyer = (sppData.buyer != null) ? sppData.buyer : sppFound.buyer; sppFound.product = (sppData.product != null) ? sppData.product : sppFound.product; sppFound.print_date = (sppData.print_date != null) ? sppData.print_date : sppFound.print_date; sppFound.verification_date = (sppData.verification_date != null) ? sppData.verification_date : sppFound.verification_date; sppFound.status = (sppData.status != null) ? sppData.status : sppFound.status; mspbu.Entry(sppFound).State = EntityState.Modified; } } return(mspbu.SaveChanges()); //int rowAffected = mspbu.SaveChanges(); //return rowAffected + " row(s) updated"; }
public int sppUpdate(spp sppData) { //spp sppRequest = (spp)convertJsonToType(sppRequestJson, typeof(Model.spp)); spp sppFound = mspbu.spps.Find(sppData.Id); if (sppFound != null) { sppFound.name = (sppData.name != null) ? sppData.name : sppFound.name; sppFound.address = (sppData.address != null) ? sppData.address : sppFound.address; sppFound.police_no = (sppData.police_no != null) ? sppData.police_no : sppFound.police_no; sppFound.shipment_no = (sppData.shipment_no != null) ? sppData.shipment_no : sppFound.shipment_no; sppFound.volume = (sppData.volume != null) ? sppData.volume : sppFound.volume; sppFound.dens_temp = (sppData.dens_temp != null) ? sppData.dens_temp : sppFound.dens_temp; sppFound.buyer = (sppData.buyer != null) ? sppData.buyer : sppFound.buyer; sppFound.product = (sppData.product != null) ? sppData.product : sppFound.product; sppFound.print_date = (sppData.print_date != null) ? sppData.print_date : sppFound.print_date; sppFound.verification_date = (sppData.verification_date != null) ? sppData.verification_date : sppFound.verification_date; sppFound.status = (sppData.status != null) ? sppData.status : sppFound.status; mspbu.Entry(sppFound).State = EntityState.Modified; return(mspbu.SaveChanges()); } return(-1); //int rowAffected = mspbu.SaveChanges(); //return rowAffected + " row updated"; }
public int sppInsert(spp sppData) { //spp sppRequest = (spp)convertJsonToType(sppRequestJson, typeof(Model.spp)); sppData.verification_date = DateTime.Now; sppData.status = "Sukses"; mspbu.spps.Add(sppData); return(mspbu.SaveChanges()); //int rowAffected = mspbu.SaveChanges(); //return rowAffected + " row inserted"; }
public int sppDelete(int sppId) { spp sppFound = mspbu.spps.Find(sppId); if (sppFound != null) { mspbu.spps.Remove(sppFound); } return(mspbu.SaveChanges()); //int rowAffected = mspbu.SaveChanges(); //return rowAffected + " row deleted"; }
public List <spp> sppGetWhere(spp sppData) { List <spp> sppFound = mspbu.spps.ToList(); if (sppData.name != null) { sppFound = sppFound.Where(s => s.name == sppData.name).ToList(); } if (sppData.address != null) { sppFound = sppFound.Where(s => s.address == sppData.address).ToList(); } if (sppData.police_no != null) { sppFound = sppFound.Where(s => s.police_no == sppData.police_no).ToList(); } if (sppData.shipment_no != null) { sppFound = sppFound.Where(s => s.shipment_no == sppData.shipment_no).ToList(); } if (sppData.volume != null) { sppFound = sppFound.Where(s => s.volume == sppData.volume).ToList(); } if (sppData.dens_temp != null) { sppFound = sppFound.Where(s => s.dens_temp == sppData.dens_temp).ToList(); } if (sppData.buyer != null) { sppFound = sppFound.Where(s => s.buyer == sppData.buyer).ToList(); } if (sppData.product != null) { sppFound = sppFound.Where(s => s.product == sppData.product).ToList(); } if (sppData.print_date != null) { sppFound = sppFound.Where(s => s.print_date == sppData.print_date).ToList(); } if (sppData.verification_date != null) { sppFound = sppFound.Where(s => s.verification_date == sppData.verification_date).ToList(); } if (sppData.status != null) { sppFound = sppFound.Where(s => s.status == sppData.status).ToList(); } return(sppFound); }
public int sppDeleteBatch(List <int> sppIdList) { //List<int> idListRequest = (List<int>)convertJsonToType(idListRequestJson, typeof(List<int>)); foreach (int sppId in sppIdList) { spp sppFound = mspbu.spps.Find(sppId); if (sppFound != null) { mspbu.spps.Remove(sppFound); } } return(mspbu.SaveChanges()); //int rowAffected = mspbu.SaveChanges(); //return rowAffected + " row(s) deleted"; }