Ejemplo n.º 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));
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Manage(string returnUrl)
        {
            var user = await _currentUserService.GetUserAsync();

            var role = await _currentUserService.GetRoleAsync();

            var vm = new ManageViewModel
            {
                UserId    = user.Id,
                UserName  = user.UserName,
                Email     = user.Email,
                FirstName = user.FirstName,
                LastName  = user.LastName,
                HasBranch = role.HasBranch,
                HasCar    = role.HasCar,
                ReturnUrl = returnUrl
            };

            if (vm.HasBranch)
            {
                vm.AllBranches = await _branchesDao.GetAllAsync();

                var branch = await _currentUserService.GetBranchAsync();

                vm.BranchId = branch?.Id ?? default(long);
            }
            if (vm.HasCar)
            {
                vm.AllCars = await _carsDao.GetAllAsync();

                var car = await _currentUserService.GetCarAsync();

                vm.CarId = car?.Id ?? default(long);
            }

            return(View(vm));
        }
Ejemplo n.º 4
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            var vm = new AccountViewModel
            {
                CurrentUrl = Request.PathAndQuery()
            };
            var isLoggedIn = User.Identity.IsAuthenticated;

            vm.IsLoggedIn = isLoggedIn;
            if (!isLoggedIn)
            {
                return(View(vm));
            }
            vm.User = await _currentUserService.GetUserAsync();

            if (vm.User == null)
            {
                vm.IsLoggedIn = false;
                return(View(vm));
            }

            var role = await _currentUserService.GetRoleAsync();

            vm.HasBranch = role.HasBranch;
            vm.HasCar    = role.HasCar;
            if (vm.HasBranch)
            {
                vm.Branch = await _currentUserService.GetBranchAsync();
            }

            if (vm.HasCar)
            {
                vm.Car = await _currentUserService.GetCarAsync();
            }
            return(View(vm));
        }