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> Index(ListOptions options) { options = options ?? DefaultListOptions; var filterModel = options.Filters["model"]; var filterNumber = options.Filters["number"]; var cars = await _carsDao.GetAllAsync( filterModel, filterNumber, options.SortKey, options.SortOrder); return(View(new IndexViewModel { Cars = cars.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() })); }