Beispiel #1
0
        public ActionResult Create(CreateBidViewModel bidViewModel)
        {
            var bid = GetBid(bidViewModel);
            if (!IsBidMadeForThisRegion(bid.RegionID, bid.TransportBidPlanID))
            {
                ModelState.AddModelError("Errors",@"This Region is already registered with this Bid Plan. Please choose another Region or Plan!");
                ViewBag.StatusID = new SelectList(_statusService.GetAllStatus(), "StatusID", "Name");
                ViewBag.BidPlanID = bid.TransportBidPlanID;
                ViewBag.TransportBidPlanID = new SelectList(_transportBidPlanService.GetAllTransportBidPlan(), "TransportBidPlanID", "ShortName", bid.TransportBidPlanID);
                ViewBag.RegionID = new SelectList(_adminUnitService.GetRegions(), "AdminUnitID", "Name");
                return View(bidViewModel);
            }

            if (ModelState.IsValid)
            {
                //var regions = _adminUnitService.FindBy(t => t.AdminUnitTypeID == 2);
                var regions = _adminUnitService.FindBy(t => t.AdminUnitID == bid.RegionID);
                bid.StatusID = (int)BidStatus.Open;

                var bidDetails = (from detail in regions
                                  select new BidDetail()
                                      {
                                          AmountForReliefProgram = (decimal)_transportBidPlanDetailService.GetRegionPlanTotal(bid.TransportBidPlanID, detail.AdminUnitID, 1),
                                          AmountForPSNPProgram = (decimal)_transportBidPlanDetailService.GetRegionPlanTotal(bid.TransportBidPlanID, detail.AdminUnitID, 2),
                                          BidDocumentPrice = 0,
                                          CPO = 0
                                          //RegionID = bid.RegionID
                                      }).ToList();
                bid.BidDetails = bidDetails;
                bid.RegionID = bid.RegionID;

                var user = (UserIdentity)System.Web.HttpContext.Current.User.Identity;
                bid.UserProfileId = user.Profile.UserProfileID;
                _bidService.AddBid(bid);

                return RedirectToAction("Index");
            }

            ViewBag.StatusID = new SelectList(_statusService.GetAllStatus(), "StatusID", "Name");
            ViewBag.BidPlanID = bid.TransportBidPlanID;
            ViewBag.TransportBidPlanID = new SelectList(_transportBidPlanService.GetAllTransportBidPlan(), "TransportBidPlanID", "ShortName", bid.TransportBidPlanID);
            ViewBag.RegionID = new SelectList(_adminUnitService.GetRegions(), "AdminUnitID", "Name");
            return View(bidViewModel);

            //return View("Index", _bidService.GetAllBid());
        }
Beispiel #2
0
        private Bid GetBid(CreateBidViewModel bidViewModel)
        {
            var bid = new Bid()
                {

                    RegionID = bidViewModel.RegionID,
                    StartDate = bidViewModel.StartDate,
                    startTime = bidViewModel.StartTime,
                    EndDate = bidViewModel.EndDate,
                    endTime = bidViewModel.EndTime,
                    BidNumber = bidViewModel.BidNumber,
                    BidBondAmount = bidViewModel.BidBondAmount,
                    OpeningDate = bidViewModel.OpeningDate,
                    BidOpeningTime = bidViewModel.BidOpningTime,
                    StatusID = bidViewModel.StatusID,
                    TransportBidPlanID = bidViewModel.TransportBidPlanID

                };
            return bid;
        }
Beispiel #3
0
        public ActionResult Create(int id = 0)
        {
            ViewBag.RegionID = new SelectList(_adminUnitService.GetRegions(), "AdminUnitID", "Name");
            var datePref = _userAccountService.GetUserInfo(HttpContext.User.Identity.Name).DatePreference;
            var bid = new CreateBidViewModel();
            bid.StartDate = DateTime.Now;
            bid.EndDate = DateTime.Now.AddDays(10);
            bid.OpeningDate = DateTime.Now.AddDays(11);
            var regions = _adminUnitService.FindBy(t => t.AdminUnitTypeID == 2);
            ViewBag.StatusID = new SelectList(_statusService.GetAllStatus(), "StatusID", "Name", bid.StatusID = 1);
            bid.BidNumber = _bidService.AutogenerateBidNo();
            ViewBag.BidPlanID = id;

            ViewBag.TransportBidPlanID = new SelectList(_transportBidPlanService.GetAllTransportBidPlan(), "TransportBidPlanID", "ShortName", id);
            return View(bid);
        }