コード例 #1
0
        public async Task <IActionResult> StockMail(ListOptions options)
        {
            options = options ?? DefaultListOptions;

            var filterPersonTo  = options.Filters["personTo"];
            var filterAddressTo = options.Filters["addressTo"];

            var vm = new MailViewModel
            {
                Mail = new PaginatedList <Post>(PageSize),
                CurrentListOptions = options,
                ReturnUrl          = HttpContext.Request.PathAndQuery()
            };

            var branch = await _currentUserService.GetBranchAsync();

            var car = await _currentUserService.GetCarAsync();

            if (branch == null || car == null)
            {
                TempData.Set("message", MessageViewModel.MakeError("Setup your branch and car"));
                return(View(vm));
            }

            var mail = await _mailDao.GetAllAsync(
                filterPersonTo : filterPersonTo,
                filterAddressTo : filterAddressTo,
                filterBranchId : branch.Id,
                filterState : PostState.InBranchStock,
                sortKey : options.SortKey,
                sortOrder : options.SortOrder);

            vm.Mail = mail.ToPaginatedList(options.Page, PageSize);
            return(View(vm));
        }
コード例 #2
0
        public async Task <IActionResult> DeliverPost(ListOptions options)
        {
            options = options ?? DefaultDeliverPostListOptions;
            var filterId         = options.Filters["id"];
            var filterPersonFrom = options.Filters["personFrom"];
            var filterPersonTo   = options.Filters["personTo"];

            var vm = new DeliverPostViewModel
            {
                CurrentListOptions = options,
                Mail      = new PaginatedList <Post>(PageSize),
                ReturnUrl = HttpContext.Request.PathAndQuery(),
            };

            var destinationBranch = await _currentUserService.GetBranchAsync();

            if (destinationBranch == null)
            {
                TempData.Set("message", MessageViewModel.MakeError("Setup your branch"));
                return(View(vm));
            }

            var mail = await _mailDao.GetAllAsync(
                filterId : filterId,
                filterPersonFrom : filterPersonFrom,
                filterPersonTo : filterPersonTo,
                filterDestinationBranchId : destinationBranch.Id,
                filterState : PostState.InBranchStock,
                sortKey : options.SortKey,
                sortOrder : options.SortOrder);

            vm.Mail = mail.ToPaginatedList(options.Page, PageSize);
            return(View(vm));
        }
コード例 #3
0
        public async Task <IActionResult> StockMail(ListOptions options)
        {
            options = options ?? DefaultListOptions;

            NullableExtensions.TryParse(options.Filters["sourceBranchId"], out long?filterSourceBranchId);
            NullableExtensions.TryParse(options.Filters["destinationBranchId"], out long?filterDestinationBranchId);

            var vm = new MailViewModel
            {
                AllBranches        = await _branchesDao.GetAllAsync(),
                Mail               = new PaginatedList <Post>(PageSize),
                CurrentListOptions = options,
                ReturnUrl          = HttpContext.Request.PathAndQuery()
            };

            var branch = await _currentUserService.GetBranchAsync();

            var car = await _currentUserService.GetCarAsync();

            if (branch == null || car == null)
            {
                TempData.Set("message", MessageViewModel.MakeError("Setup your branch and car"));
                return(View(vm));
            }

            var mail = await _mailDao.GetAllAsync(
                filterBranchId : branch.Id,
                filterSourceBranchId : filterSourceBranchId,
                filterDestinationBranchId : filterDestinationBranchId,
                filterState : PostState.InBranchStock,
                sortKey : options.SortKey,
                sortOrder : options.SortOrder);

            vm.Mail = mail.ToPaginatedList(options.Page, PageSize);
            return(View(vm));
        }