public ActionResult ReadWoredasWithOutBidOffer([DataSourceRequest] DataSourceRequest request, int bidID, int regionID) { var planID = _bidService.FindById(bidID).TransportBidPlanID; var bidPlanDetail = _transportBidPlanDetailService.FindBy(t => t.Destination.AdminUnit2.AdminUnit2.AdminUnitID == regionID && t.BidPlanID == planID); var df = (from planDetail in bidPlanDetail group planDetail by new { planDetail.DestinationID, planDetail.SourceID } into gr select gr ); var detailPlans = df.Select(d => d.ToList()).Select(er => er.FirstOrDefault()).ToList(); var result = new List <PriceQuotationDetail>(); foreach (var transportBidPlanDetail in detailPlans) { var pdetail = transportBidPlanDetail; var detail = _transportBidQuotationService.FindBy(t => t.BidID == bidID && t.SourceID == pdetail.SourceID && t.DestinationID == pdetail.DestinationID).FirstOrDefault(); if (detail == null) { var n = new PriceQuotationDetail() { SourceWarehouse = pdetail.Source.Name, Zone = pdetail.Destination.AdminUnit2.Name, Woreda = pdetail.Destination.Name, Tariff = 0, Remark = String.Empty, BidID = bidID, DestinationID = pdetail.DestinationID, SourceID = pdetail.SourceID }; result.Add(n); } } return(Json(result.ToDataSourceResult(request), JsonRequestBehavior.AllowGet)); }
public List <PriceQuotationDetailViewModel> populateForm(PriceQuotationFilterViewModel model) { Session["PriceQuotationFilter"] = model; LoadLookups(); ViewBag.ModelFilter = model; ViewBag.SelectedRegion = _adminUnitService.FindById(model.RegionID); int bidID = model.BidID; ViewBag.SelectedTransporter = _transporterService.FindById(model.TransporterID); Bid SelectedBid = _bidService.FindById(bidID); ViewBag.SelectedBid = SelectedBid; int bidPlanID = SelectedBid.TransportBidPlanID; List <GoodsMovementDetailViewModel> quotationDestinations = GetPlannedDistribution(bidPlanID, model.RegionID); List <PriceQuotationDetailViewModel> qoutation = GetPriceQuotation(quotationDestinations, model.TransporterID, bidID); // return View(qoutation); List <TransportBidQuotation> transporterQuote = _bidQuotationService.FindBy(t => t.BidID == bidID && t.TransporterID == model.TransporterID); Dictionary <string, PriceQuotationDetailViewModel> transporterQuoteDictionary = organizeList(qoutation); foreach (TransportBidQuotation i in transporterQuote) { string hash = i.BidID + "_" + i.TransporterID + "_" + i.SourceID + "_" + i.DestinationID; if (transporterQuoteDictionary.ContainsKey(hash)) { PriceQuotationDetailViewModel pq = transporterQuoteDictionary[hash]; pq.TransportBidQuotationID = i.TransportBidQuotationID; pq.Tariff = (int)i.Tariff; pq.Remark = i.Remark; pq.IsWinner = i.IsWinner; pq.Rank = i.Position; } } return(qoutation); }
//[ProcurementAuthorize(operation = ProcurementCheckAccess.Operation.Bid_Planning)] public ActionResult SaveBidProposals([DataSourceRequest] DataSourceRequest request, List <PriceQuotationDetail> models) { foreach (PriceQuotationDetail bidProposal in models) { if (bidProposal != null && ModelState.IsValid) { //var detail = _transportBidQuotationService.FindById(bidProposal.TransportBidQuotationID); var detai = _transportBidQuotationService.FindBy(t => t.BidID == bidProposal.BidID && t.SourceID == bidProposal.SourceID && t.DestinationID == bidProposal.DestinationID && t.TransporterID == bidProposal.TransporterID); var detail = detai.FirstOrDefault(); if (detail != null) { //detail.TransportBidQuotationID = bidProposal.TransportBidQuotationID; detail.BidID = bidProposal.BidID; detail.TransportBidQuotationHeaderID = bidProposal.HeaderId; detail.TransporterID = bidProposal.TransporterID; detail.SourceID = bidProposal.SourceID; detail.DestinationID = bidProposal.DestinationID; detail.Tariff = bidProposal.Tariff; detail.Remark = bidProposal.Remark ?? String.Empty; detail.IsWinner = false; try { _transportBidQuotationService.UpdateTransportBidQuotation(detail); } catch (Exception e) { } } else { var newProposal = new TransportBidQuotation(); //newProposal.TransportBidQuotationID = bidProposal.TransportBidQuotationID; newProposal.BidID = bidProposal.BidID; newProposal.TransportBidQuotationHeaderID = bidProposal.HeaderId; newProposal.TransporterID = bidProposal.TransporterID; newProposal.SourceID = bidProposal.SourceID; newProposal.DestinationID = bidProposal.DestinationID; newProposal.Tariff = bidProposal.Tariff; newProposal.Remark = bidProposal.Remark ?? String.Empty; newProposal.IsWinner = false; try { _transportBidQuotationService.AddTransportBidQuotation(newProposal); } catch (Exception e) { } } //int region = _adminUnitService.FindById(bidProposal.DestinationID).AdminUnit2.AdminUnit2.AdminUnitID; //var changeable = _transportBidQuotationService.FindBy(t => // t.BidID == bidProposal.BidID); //foreach (var transportBidQuotation in changeable) //{ // transportBidQuotation.IsWinner = false; // _transportBidQuotationService.UpdateTransportBidQuotation(transportBidQuotation); //} } } return(Json(models.ToDataSourceResult(request, ModelState))); }