public bool UpdateTransportBidQuotation(TransportBidQuotation item) { if (item == null) return false; _unitOfWork.TransportBidQuotationRepository.Edit(item); _unitOfWork.Save(); return true; }
public bool AddTransportBidQuotation(TransportBidQuotation item) { _unitOfWork.TransportBidQuotationRepository.Add(item); _unitOfWork.Save(); return true; }
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)); }
public ActionResult EditAjax([DataSourceRequest] DataSourceRequest request, PriceQuotationDetailViewModel item) { if (ModelState.IsValid) { List<TransportBidQuotation> existing = _bidQuotationService.FindBy(t => t.BidID == item.BidID && t.TransporterID == item.TransporterID && t.SourceID == item.SourceID && t.DestinationID == item.DestinationID ); var edited = new TransportBidQuotation(); if (existing.Count == 1) { edited = existing[0]; } // transportQuote.TransportBidQuotationID = edited.TransportBidQuotationID; edited.Tariff = item.Tariff; edited.Remark = item.Remark; edited.Position = item.Rank; edited.IsWinner = item.IsWinner; edited.TransporterID = item.TransporterID; edited.SourceID = item.SourceID; edited.DestinationID = item.DestinationID; edited.BidID = item.BidID; // edited. if (existing.Count == 1) { _bidQuotationService.UpdateTransportBidQuotation(edited); } else { _bidQuotationService.AddTransportBidQuotation(edited); } return Json(new[] { item }.ToDataSourceResult(request, ModelState)); } return Json("{}", JsonRequestBehavior.AllowGet); }
public ActionResult Edit(TransportBidQuotation transportQuote) { if (ModelState.IsValid) { List<TransportBidQuotation> existing = _bidQuotationService.FindBy(t => t.BidID == transportQuote.BidID && t.TransporterID == transportQuote.TransporterID && t.SourceID == transportQuote.SourceID && t.DestinationID == transportQuote.DestinationID ); if (existing.Count == 1) { TransportBidQuotation edited = existing[0]; // transportQuote.TransportBidQuotationID = edited.TransportBidQuotationID; edited.Tariff = transportQuote.Tariff; edited.Remark = transportQuote.Remark; edited.Position = transportQuote.Position; edited.IsWinner = transportQuote.IsWinner; _bidQuotationService.UpdateTransportBidQuotation(edited); } else { _bidQuotationService.AddTransportBidQuotation(transportQuote); } return View(transportQuote); } return RedirectToAction("Index"); }
public ActionResult SaveBidProposals([DataSourceRequest] DataSourceRequest request, PriceQuotationDetail bidProposal) { 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; _transportBidQuotationService.UpdateTransportBidQuotation(detail); } 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; _transportBidQuotationService.AddTransportBidQuotation(newProposal); } int region = _adminUnitService.FindById(bidProposal.DestinationID).AdminUnit2.AdminUnit2.AdminUnitID; var changeable = _transportBidQuotationService.FindBy(t => t.BidID == bidProposal.BidID /* && t.Destination.AdminUnit2.AdminUnit2.AdminUnitID == region*/); //var changeable = _transportBidQuotationService.FindBy(t => // t.BidID == bidProposal.BidID // && t.Destination.AdminUnit2.AdminUnit2.AdminUnitID == region); foreach (var transportBidQuotation in changeable) { transportBidQuotation.IsWinner = false; _transportBidQuotationService.UpdateTransportBidQuotation(transportBidQuotation); } } return Json(new[] { bidProposal }.ToDataSourceResult(request, ModelState)); //return Json(ModelState.ToDataSourceResult()); }
// BidId should also be used to filter the data public List<TransportBidQuotation> GetSecondWinner(int transporterId, int woredaId) { var secondTransporter = 2; const int firstTransporter = 1; var bidQoutation = _unitOfWork.TransportBidQuotationRepository.FindBy( t => t.DestinationID == woredaId && t.TransporterID != transporterId); var secondWinner = new List<TransportBidQuotation>(); var winnerTransporter = new List<TransportBidQuotation>(); if (bidQoutation.Count > 0) { if (bidQoutation.Count == 1) secondTransporter = 1; secondWinner = bidQoutation .GroupBy(g => g.TransportBidQuotationID) .OrderByDescending(o => o.Key) .Select(s => new {Qoutation = s.ToList()}) .ToList()[secondTransporter - 1].Qoutation; } //DRMFSS var drmfssTransporters = GetDrmfssTransporters().Where(m=>m.TransporterID!=transporterId); foreach (var transporter in drmfssTransporters) { var drmfssTransporter = new TransportBidQuotation { TransporterID = transporter.TransporterID}; var drmfssTransporterHeaderInfo = new TransportBidQuotationHeader() { TransporterId = transporter.TransporterID, Transporter = _unitOfWork.TransporterRepository.FindById(transporter.TransporterID) }; drmfssTransporter.TransportBidQuotationHeader = drmfssTransporterHeaderInfo; secondWinner.Add(drmfssTransporter); } return secondWinner; }