Ejemplo n.º 1
0
        public ActionResult RankAdvancement(int id)
        {
            var currentPeriod = ExigoDAL.GetCurrentPeriod(PeriodTypes.Default);

            int result;

            using (var context = ExigoDAL.Sql())
            {
                result = context.Query <int>(@"
                    SELECT 
                        ISNULL(pv.PaidRankID, 1)	
                    FROM
	                    PeriodVolumes pv		                            
                    WHERE pv.CustomerID = @customerid
	                    AND pv.PeriodTypeID = @periodtypeid
	                    AND pv.PeriodID = @periodid
                ", new
                {
                    customerid   = id,
                    periodtypeid = currentPeriod.PeriodTypeID,
                    periodid     = currentPeriod.PeriodID
                }).FirstOrDefault();
            }

            var paidRankID = 1;

            if (result > 0)
            {
                paidRankID = result;
            }

            var ranks = RankService.GetRanks().ToList();

            if (ranks.Last().RankID != paidRankID)
            {
                paidRankID = ranks.OrderBy(c => c.RankID).Where(c => c.RankID > paidRankID).FirstOrDefault().RankID;
            }

            var model = RankQualificationService.GetCustomerRankQualifications(new GetCustomerRankQualificationsRequest
            {
                CustomerID   = id,
                PeriodTypeID = PeriodTypes.Default,
                RankID       = paidRankID
            });

            return(PartialView("Partials/RankAdvancement", model));
        }
Ejemplo n.º 2
0
        public ActionResult Rank()
        {
            var model = new RankViewModel();

            //Pull in all the ranks
            model.Ranks = RankService.GetRanks().OrderBy(c => c.RankID);

            var currentperiod = ExigoDAL.GetCurrentPeriod(PeriodTypes.Default);

            //Get the current rank from the current paid as rank from the current commission period
            model.CurrentRank = ExigoDAL.GetCustomerVolumes(new GetCustomerVolumesRequest
            {
                CustomerID   = Identity.Current.CustomerID,
                PeriodTypeID = currentperiod.PeriodTypeID,
                PeriodID     = currentperiod.PeriodID
            }).PayableAsRank;

            //Get the next rank so we can jump to the next qualification
            model.NextRank = model.Ranks.OrderBy(c => c.RankID).Where(c => c.RankID > model.CurrentRank.RankID).FirstOrDefault();
            return(View(model));
        }
        public ActionResult GetRankAdvancementCard(int rankid)
        {
            var ranks      = RankService.GetRanks().ToList();
            var customerID = Identity.Current.CustomerID;

            GetCustomerRankQualificationsResponse model = null;

            // Check to ensure that the rank we are checking is not the last rank.
            // If so, return a null. Our view will take care of nulls specially.
            if (ranks.Last().RankID != rankid)
            {
                var nextRankID = ranks.OrderBy(c => c.RankID).Where(c => c.RankID > rankid).FirstOrDefault().RankID;
                model = RankQualificationService.GetCustomerRankQualifications(new GetCustomerRankQualificationsRequest
                {
                    CustomerID   = Identity.Current.CustomerID,
                    PeriodTypeID = PeriodTypes.Default,
                    RankID       = nextRankID
                });
            }

            return(PartialView("Cards/RankAdvancement", model));
        }