public FileResult Print(int bidID, int regionID) { var datePref = _userAccountService.GetUserInfo(HttpContext.User.Identity.Name).DatePreference; var reportPath = Server.MapPath("~/Report/Procurment/RFQ.rdlc"); var bid = _bidService.FindById(bidID); var planID = bid.TransportBidPlanID; TransportBidPlan bidPlan = _transportBidPlanService.FindById(planID); List <TransportBidPlanDetail> regionalPlan = _transportBidPlanDetailService.FindBy(t => t.BidPlanID == planID && t.Destination.AdminUnit2.AdminUnit2.AdminUnitID == regionID); var totalReliefAmount = regionalPlan.Where(m => m.ProgramID == 1).Sum(m => m.Quantity); var totalPsnpAmount = regionalPlan.Where(m => m.ProgramID == 2).Sum(m => m.Quantity); var rfqDetail = (from transportBidPlanDetail in regionalPlan select new RfqPrintViewModel { Source = transportBidPlanDetail.Source.Name, Zone = transportBidPlanDetail.Destination.AdminUnit2.Name, Woreda = transportBidPlanDetail.Destination.Name, WoredaID = transportBidPlanDetail.DestinationID, Region = transportBidPlanDetail.Destination.AdminUnit2.AdminUnit2.Name, BidReference = bid.BidNumber, ProgramID = transportBidPlanDetail.ProgramID, Quantity = transportBidPlanDetail.Quantity / 10, BidOpeningdate = bid.OpeningDate.ToCTSPreferedDateFormat(datePref), BidOpeningTime = bid.startTime } ).Where(m => m.Quantity > 0) .GroupBy(ac => new { ac.Woreda, ac.Source, ac.Region, ac.Zone }) .Select(ac => new RfqPrintViewModel { Source = ac.Key.Source, Zone = ac.Key.Zone, Woreda = ac.Key.Woreda, Region = ac.Key.Region, BidReference = bid.BidNumber, Quantity = ac.Sum(m => m.Quantity), ReliefAmount = totalReliefAmount / 10, PsnpAmount = totalPsnpAmount / 10, BidOpeningdate = bid.OpeningDate.ToCTSPreferedDateFormat(datePref), BidOpeningTime = bid.startTime }); var reportData = rfqDetail; var dataSourceName = "RFQDataset"; var result = ReportHelper.PrintReport(reportPath, reportData, dataSourceName); return(File(result.RenderBytes, result.MimeType)); }
public List <AgreementVersionViewModel> AgreementVersionListViewModelBinder(List <TransporterAgreementVersion> transporterAgreementVersions) { var agreementVersionViewModels = new List <AgreementVersionViewModel>(); foreach (var transporterAgreementVersion in transporterAgreementVersions) { var agreementVersionViewModel = new AgreementVersionViewModel(); agreementVersionViewModel.TransporterID = transporterAgreementVersion.TransporterID; agreementVersionViewModel.Transporter = _transporterService.FindById(transporterAgreementVersion.TransporterID).Name; agreementVersionViewModel.BidNo = _bidService.FindById(transporterAgreementVersion.BidID).BidNumber; agreementVersionViewModel.BidID = transporterAgreementVersion.BidID; agreementVersionViewModel.IssueDate = transporterAgreementVersion.IssueDate.ToString(); agreementVersionViewModel.Current = transporterAgreementVersion.Current.ToString(); agreementVersionViewModel.TransportAgreementVersionID = transporterAgreementVersion.TransporterAgreementVersionID; switch (transporterAgreementVersion.Status) { case 1: agreementVersionViewModel.StatusName = "Draft"; break; case 2: agreementVersionViewModel.StatusName = "Approved"; break; default: agreementVersionViewModel.StatusName = "Draft"; break; } agreementVersionViewModels.Add(agreementVersionViewModel); } return(agreementVersionViewModels); }
public IActionResult GetById(int id) { AppLogger.LogResourceRequest(nameof(GetById), base.GetUsernameForRequest()); try { var bid = _bidService.FindById(id); if (bid == null) { return(NotFound(AppConfig.ResourceNotFoundById + id)); } return(Ok(bid)); } catch (Exception ex) { return(BadRequestExceptionHandler(ex, nameof(GetById))); } }
public ActionResult LoadBidWinnerLeave(WoredaBidWinnerViewModel woredaBidWinnerViewModel) { if (woredaBidWinnerViewModel == null || woredaBidWinnerViewModel.SourceId <= 0 || woredaBidWinnerViewModel.DestinationId <= 0 || woredaBidWinnerViewModel.BidID <= 0) { return(Json(new SelectList(Enumerable.Empty <SelectListItem>()), JsonRequestBehavior.AllowGet)); } woredaBidWinnerViewModel.Woreda = _adminUnitService.FindById(woredaBidWinnerViewModel.DestinationId).Name; woredaBidWinnerViewModel.SourceWarehouse = _hubService.FindById(woredaBidWinnerViewModel.SourceId).Name; woredaBidWinnerViewModel.BidNumber = _bidService.FindById(woredaBidWinnerViewModel.BidID).BidNumber; var bidWinners = _bidWinnerService.Get( t => t.SourceID == woredaBidWinnerViewModel.SourceId && t.DestinationID == woredaBidWinnerViewModel.DestinationId && t.BidID == woredaBidWinnerViewModel.BidID && t.Position == 1 && t.Status == 1).Select( t => t.Transporter).ToList(); var transporters = bidWinners.Select(i => new SelectListItemModel { Name = i.Name, Id = i.TransporterID.ToString() }). ToList(); //transporters.Add(new SelectListItemModel { Name = "N/A", Id = "0" }); //TODO just a hack for now for unknown stacks woredaBidWinnerViewModel.Transporters = new SelectList(transporters, "Id", "Name"); return(Json(woredaBidWinnerViewModel, JsonRequestBehavior.AllowGet)); }
public ActionResult WoredasWithoutOffer_Read([DataSourceRequest] DataSourceRequest request, int BIDID) { var bid = _bidService.FindById(BIDID); var bidPlanDetail = _bidPlanService.FindById(bid.TransportBidPlanID); var planned = (from planDetail in bidPlanDetail.TransportBidPlanDetails group planDetail by new { planDetail.DestinationID, planDetail.SourceID } into grouped select grouped ); var detailPlans = planned.Select(d => d.ToList()).Select(er => er.FirstOrDefault()).ToList(); var result = new List <BidWinnerViewModel>(); foreach (TransportBidPlanDetail pdetail in detailPlans) { var detail = _bidWinnerService.FindBy(t => t.BidID == BIDID && t.SourceID == pdetail.SourceID && t.DestinationID == pdetail.DestinationID).FirstOrDefault(); if (detail == null) { result.Add(new BidWinnerViewModel() { SourceWarehouse = pdetail.Source.Name, Zone = pdetail.Destination.AdminUnit2.Name, Region = pdetail.Destination.AdminUnit2.AdminUnit2.Name, Woreda = pdetail.Destination.Name, BidID = BIDID, DestinationId = pdetail.DestinationID, SourceId = pdetail.SourceID }); } } 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); }