예제 #1
0
        private async Task <NewLetterModel> GetDistributorsInformation(List <string> distNums)
        {
            try
            {
                var oldDistributor = _distributorService.GetDistributorById(long.Parse(distNums[0]));
                var distributor    = _distributorService.GetDistributorById(long.Parse(distNums[1]));
                var sponsor        = _distributorService.GetDistributorById(long.Parse(distNums[2]));
                var platium        = _distributorService.GetDistributorById(long.Parse(distNums[3]));

                if (oldDistributor == null || distributor == null || sponsor == null || platium == null)
                {
                    return(null);
                }
                else
                {
                    return(new NewLetterModel {
                        OldDistName = oldDistributor.Name, DistName = distributor.Name, SponsorName = sponsor.Name, PlatiumName = platium.Name
                    });
                }
            }
            catch (Exception ex)
            {
                _logger.WriteLog(ex.Message, ex);

                return(null);
            }
        }
예제 #2
0
        public ActionResult Index(long?distNumber = null, int page = 1, int pageSize = 10, GridSortOptions sort = null)
        {
            var model = new ProfileIndexModel();

            if (distNumber.HasValue)
            {
                // Set distributor data
                var distributor = _distributorService.GetDistributorById(distNumber.Value);
                if (distributor != null)
                {
                    model.Distributor = distributor.ToModel <ProfileIndexModel.DistributorModel>();
                }

                // Set profile box data
                if (sort == null || string.IsNullOrEmpty(sort.Column))
                {
                    sort = new GridSortOptions()
                    {
                        Column = "CreatedDate", Direction = SortDirection.Descending
                    }
                }
                ;
                ViewBag.Sort = sort;

                var boxes = _profileService.SearchProfilesByDistNumber(
                    distNumber.Value,
                    page,
                    pageSize,
                    sort.Column,
                    WebUtility.GetSortDir(sort));
                model.ProfileBoxes = boxes.Select(x => x.ToModel <ProfileIndexModel.ProfileModel>()).ToList();
                model.Pager        = boxes.ToMvcPaging(model.ProfileBoxes);

                // If current page > total pages, redirect to last page
                if (model.Pager.TotalPages > 0 && model.Pager.PageNumber > model.Pager.TotalPages)
                {
                    return(Redirect(Url.Paging(model.Pager.TotalPages, model.Pager.PageSize).ToString()));
                }
            }

            return(View(model));
        }