public bool DeleteTransportBidPlanDetail(TransportBidPlanDetail item) { if (item == null) return false; _unitOfWork.TransportBidPlanDetailRepository.Delete(item); _unitOfWork.Save(); return true; }
public ActionResult Create(TransportBidPlanDetail transportbidplandetail) { if (ModelState.IsValid) { db.TransportBidPlanDetails.Add(transportbidplandetail); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.BidPlanID = new SelectList(db.TransportBidPlans, "TransportBidPlanID", "TransportBidPlanID", transportbidplandetail.BidPlanID); ViewBag.DestinationID = new SelectList(db.AdminUnits, "AdminUnitID", "Name", transportbidplandetail.DestinationID); ViewBag.SourceID = new SelectList(db.Hubs, "HubId", "Name", transportbidplandetail.SourceID); ViewBag.ProgramID = new SelectList(db.Programs, "ProgramID", "Name", transportbidplandetail.ProgramID); return View(transportbidplandetail); }
public bool AddTransportBidPlanDetail(TransportBidPlanDetail item) { _unitOfWork.TransportBidPlanDetailRepository.Add(item); _unitOfWork.Save(); return true; }
public ActionResult UpdateWarehouseSelectionAjax([DataSourceRequest] DataSourceRequest request, WarehouseProgramViewModel WarehouseAllocation) { if (WarehouseAllocation != null && ModelState.IsValid) { List<TransportBidPlanDetail> inDb = _transportBidPlanDetailService.FindBy(w => w.BidPlanID == WarehouseAllocation.BidPlanID && w.DestinationID == WarehouseAllocation.WoredaID && w.SourceID == WarehouseAllocation.WarehouseID ); TransportBidPlanDetail psnp = new TransportBidPlanDetail { BidPlanID = WarehouseAllocation.BidPlanID, SourceID = WarehouseAllocation.WarehouseID, DestinationID = WarehouseAllocation.WoredaID, Quantity = WarehouseAllocation.PSNP, ProgramID=2 }; UpdateBidPlanDetail(psnp); TransportBidPlanDetail relief = new TransportBidPlanDetail { BidPlanID = WarehouseAllocation.BidPlanID, SourceID = WarehouseAllocation.WarehouseID, DestinationID = WarehouseAllocation.WoredaID, Quantity = WarehouseAllocation.Relief, ProgramID = 1 }; UpdateBidPlanDetail(relief); } return Json(new[] { WarehouseAllocation }.ToDataSourceResult(request, ModelState)); }
public void UpdateBidPlanDetail(TransportBidPlanDetail bpd) { List<TransportBidPlanDetail> inDb = _transportBidPlanDetailService.FindBy(w => w.BidPlanID == bpd.BidPlanID && w.DestinationID == bpd.DestinationID && w.SourceID == bpd.SourceID && w.ProgramID == bpd.ProgramID ); if (inDb.Count <= 0) { _transportBidPlanDetailService.AddTransportBidPlanDetail(bpd); } else { TransportBidPlanDetail bpd_orignal = inDb[0]; bpd_orignal.Quantity = bpd.Quantity; _transportBidPlanDetailService.UpdateTransportBidPlanDetail(bpd_orignal); } }
public ActionResult CreateWarehouseSelectionAjax([DataSourceRequest] DataSourceRequest request,WarehouseProgramViewModel warehouseAllocation, int transportBidPlanID, int selectedWoreda = 0) { if (warehouseAllocation!=null && ModelState.IsValid) { var reliefDetail = new TransportBidPlanDetail() { BidPlanID = transportBidPlanID, DestinationID = selectedWoreda, SourceID = warehouseAllocation.WarehouseID, ProgramID = 1, Quantity = _transportBidPlanDetailService.GetHrdCommodityAmount(selectedWoreda), }; UpdateBidPlanDetail(reliefDetail); var psnpDetail = new TransportBidPlanDetail() { BidPlanID = transportBidPlanID, DestinationID = selectedWoreda, SourceID = warehouseAllocation.WarehouseID, ProgramID = 2, Quantity = _transportBidPlanDetailService.GetWoredaGroupedPsnpAmount(selectedWoreda), }; UpdateBidPlanDetail(psnpDetail); } return Json(new[] { warehouseAllocation }.ToDataSourceResult(request, ModelState)); }