public async Task <IActionResult> CreatePost() { return(View(new CreatePostViewModel { AllBranches = await _branchesDao.GetAllAsync() })); }
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)); }
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)); }
public async Task <IActionResult> Index(ListOptions options) { options = options ?? DefaultStockMailListOptions; var vm = new IndexViewModel { AllBranches = await _branchesDao.GetAllAsync(), Mail = new PaginatedList <Post>(PageSize), CurrentListOptions = options, ReturnUrl = HttpContext.Request.PathAndQuery() }; if (!bool.TryParse(options.Filters["withoutAddressOnly"], out bool withoutAddresOnly)) { withoutAddresOnly = false; } NullableExtensions.TryParse(options.Filters["sourceBranchId"], out long?filterSourceBranchId); NullableExtensions.TryParse(options.Filters["destinationBranchId"], out long?filterDestinationBranchId); var filterPersonFrom = options.Filters["personFrom"]; var filterPersonTo = options.Filters["personTo"]; var filterAddressTo = options.Filters["addressTo"]; var branch = await _currentUserService.GetBranchAsync(); if (branch == null) { TempData.Set("message", MessageViewModel.MakeError("Setup your branch")); return(View(vm)); } var mail = await _mailDao.GetAllForStock( branch : branch, withoutAddressOnly : withoutAddresOnly, filterSourceBranchId : filterSourceBranchId, filterDestinationBranchId : filterDestinationBranchId, filterPersonFrom : filterPersonFrom, filterPersonTo : filterPersonTo, filterAddressTo : filterAddressTo, sortKey : options.SortKey, sortOrder : options.SortOrder); vm.Mail = mail.ToPaginatedList(options.Page, PageSize); return(View(vm)); }
public async Task <IActionResult> Index(ListOptions options) { options = options ?? DefaultListOptions; var filterName = options.Filters["name"]; var filterAddress = options.Filters["address"]; var branches = await _branchesDao.GetAllAsync( filterName, filterAddress, options.SortKey, options.SortOrder); return(View(new IndexViewModel { Branches = branches.ToPaginatedList(options.Page, PageSize), CurrentListOptions = options, ReturnUrl = HttpContext.Request.PathAndQuery() })); }
public async Task <IActionResult> Index(ListOptions options) { if (options == null) { options = DefaultListOptions; options.Filters["from"] = DateTime.Now.AddHours(-1).ToString("g"); } NullableExtensions.TryParse(options.Filters["type"], out ActivityType? filterType); var filterMessage = options.Filters["message"]; NullableExtensions.TryParse(options.Filters["from"], out DateTime? filterFrom); NullableExtensions.TryParse(options.Filters["to"], out DateTime? filterTo); var filterUser = options.Filters["user"]; NullableExtensions.TryParse(options.Filters["postId"], out long?filterPostId); NullableExtensions.TryParse(options.Filters["branchId"], out long?filterBranchId); NullableExtensions.TryParse(options.Filters["carId"], out long?filterCarId); var activities = await _activitiesDao.GetAllAsync( filterType, filterMessage, filterFrom, filterTo, filterUser, filterPostId, filterBranchId, filterCarId); return(View(new IndexViewModel { AllActivityTypes = Activity.AllTypes, AllBranches = await _branchesDao.GetAllAsync(), AllCars = await _carsDao.GetAllAsync(), Activities = activities.ToPaginatedList(options.Page, PageSize), CurrentListOptions = options, ReturnUrl = HttpContext.Request.PathAndQuery() })); }