public async Task OnNavigatedTo(NavigationParameters parameters) { if (parameters.ContainsKey("CurrentDate")) { var date = (DateTime)parameters["CurrentDate"]; Calendar = await _repo.FindAsync(date) ?? new Calendar() { Date = date }; } }
public async Task <IActionResult> GetCalendar(int year, int month, int page) { year = year == 0 ? DateTime.Now.Year : year; month = month == 0 ? DateTime.Now.Month : month; page = page == 0 ? 1 : page; int resultsPerPage = 3; int employeeCount = await _employeeRepository.CountAsync(); int maxPages = (int)Math.Ceiling(((double)employeeCount) / resultsPerPage); IEnumerable <CalendarDayViewModel> calendarDays = _mapper.Map <IEnumerable <CalendarDayViewModel> >(await _calendarRepository.FindAsync(year, month)); List <CalendarEmployeeViewModel> employees = _mapper.Map <IEnumerable <CalendarEmployeeViewModel> >(await _employeeRepository.FindAsync(page, resultsPerPage)).ToList(); int userId = 0; if (User.Identity.IsAuthenticated) { userId = Int32.Parse(User.Claims.Single(x => x.Type == ApplicationClaimTypes.UserId).Value); } bool isAdmin = User.IsInRole(Roles.Admin); CalendarViewModel retVal = new CalendarViewModel(employees, calendarDays, userId, isAdmin, maxPages); return(Json(retVal)); }