Example #1
0
        public ActionResult LoadBidWinnerCancel(WoredaCancelBidWinnerViewModel woredaCancelBidWinnerViewModel)
        {
            if (woredaCancelBidWinnerViewModel == null || woredaCancelBidWinnerViewModel.SourceId <= 0 ||
                woredaCancelBidWinnerViewModel.DestinationId <= 0 || woredaCancelBidWinnerViewModel.BidID <= 0)
            {
                return(Json(new EmptyResult(), JsonRequestBehavior.AllowGet));
            }
            woredaCancelBidWinnerViewModel.Woreda          = _adminUnitService.FindById(woredaCancelBidWinnerViewModel.DestinationId).Name;
            woredaCancelBidWinnerViewModel.SourceWarehouse = _hubService.FindById(woredaCancelBidWinnerViewModel.SourceId).Name;
            woredaCancelBidWinnerViewModel.BidNumber       = _bidService.FindById(woredaCancelBidWinnerViewModel.BidID).BidNumber;
            var bidFirstWinners =
                _bidWinnerService.Get(
                    t =>
                    t.SourceID == woredaCancelBidWinnerViewModel.SourceId &&
                    t.DestinationID == woredaCancelBidWinnerViewModel.DestinationId &&
                    t.BidID == woredaCancelBidWinnerViewModel.BidID && t.Position == 1 && t.Status == 1).Select(
                    t => t.Transporter).ToList();
            var bidSecondWinners =
                _bidWinnerService.Get(
                    t =>
                    t.SourceID == woredaCancelBidWinnerViewModel.SourceId &&
                    t.DestinationID == woredaCancelBidWinnerViewModel.DestinationId &&
                    t.BidID == woredaCancelBidWinnerViewModel.BidID && t.Position == 2 && t.Status == 1).Select(
                    t => t.Transporter).ToList();

            woredaCancelBidWinnerViewModel.CanceledTransporters = bidFirstWinners.Select(t => t.Name).ToList();
            woredaCancelBidWinnerViewModel.PromotedTransporters = bidSecondWinners.Select(t => t.Name).ToList();
            return(Json(woredaCancelBidWinnerViewModel, JsonRequestBehavior.AllowGet));
        }
Example #2
0
        public ActionResult CancelBidWinners(WoredaCancelBidWinnerViewModel woredaCancelBidWinnerViewModel)
        {
            var canceledBidWinnerObj = _bidWinnerService.Get(t => t.SourceID == woredaCancelBidWinnerViewModel.SourceId && t.DestinationID == woredaCancelBidWinnerViewModel.DestinationId &&
                                                             t.BidID == woredaCancelBidWinnerViewModel.BidID && t.Position == 1 && t.Status == 1);

            if (canceledBidWinnerObj != null)
            {
                foreach (var bidWinner in canceledBidWinnerObj)
                {
                    bidWinner.Status = (int)BIDWINNER.Failed;
                    _bidWinnerService.EditBidWinner(bidWinner);
                }
            }
            var promotedBidWinnerObj = _bidWinnerService.Get(t => t.SourceID == woredaCancelBidWinnerViewModel.SourceId && t.DestinationID == woredaCancelBidWinnerViewModel.DestinationId &&
                                                             t.BidID == woredaCancelBidWinnerViewModel.BidID && t.Position == 2 && t.Status == 1);

            if (promotedBidWinnerObj != null)
            {
                foreach (var bidWinner in promotedBidWinnerObj)
                {
                    bidWinner.Position = 1;
                    bidWinner.Status   = (int)BIDWINNER.Awarded;
                    _bidWinnerService.EditBidWinner(bidWinner);
                }
            }
            return(RedirectToAction("WoredasBidStatus"));
        }