Esempio n. 1
0
        public void LoadSelectListData(AuditFileExportVM VM)
        {
            VM.UsersList = usersAPIService.GetUsers().Select(x => new SelectListItem
            {
                Text  = x.Name,
                Value = x.UserId.ToString(),
            }).ToList();

            VM.YearsList = new List <SelectListItem>();
            for (int year = 2020; year <= DateTime.Today.Year; year++)
            {
                VM.YearsList.Add(new SelectListItem
                {
                    Text     = year.ToString(),
                    Value    = year.ToString(),
                    Selected = year == VM.SearchRequest.Year
                });
            }

            VM.MonthsList = new List <SelectListItem>();
            for (int month = 1; month <= 12; month++)
            {
                var date = new DateTime(DateTime.Today.Year, month, 1);

                VM.MonthsList.Add(new SelectListItem
                {
                    Text  = date.ToString("MMMM"),
                    Value = date.Month.ToString()
                });
            }
        }
Esempio n. 2
0
        private void LoadSelectListData(TimeSheetIndexVM VM)
        {
            VM.UsersList = usersAPIService.GetUsers().Select(x => new SelectListItem
            {
                Text     = x.Name,
                Value    = x.UserId.ToString(),
                Selected = (VM.SearchRequest.UserId != null && x.UserId == VM.SearchRequest.UserId)
            }).ToList();

            VM.YearsList = new List <SelectListItem>();
            for (int year = 2020; year <= DateTime.Today.Year; year++)
            {
                VM.YearsList.Add(new SelectListItem
                {
                    Text     = year.ToString(),
                    Value    = year.ToString(),
                    Selected = year == VM.SearchRequest.Year
                });
            }

            VM.MonthsList = new List <SelectListItem>();
            for (int month = 1; month <= 12; month++)
            {
                var date = new DateTime(DateTime.Today.Year, month, 1);

                VM.MonthsList.Add(new SelectListItem
                {
                    Text     = date.ToString("MMMM"),
                    Value    = date.Month.ToString(),
                    Selected = month == VM.SearchRequest.Month
                });
            }

            VM.DayTypeList = Enum.GetValues(typeof(DayType)).Cast <DayType>().Select(x => new SelectListItem
            {
                Text  = x.GetDescription(),
                Value = ((int)x).ToString()
            }).ToList();
        }
 public List <UserDTO> GetUsers()
 {
     return(usersAPIService.GetUsers());
 }