Exemple #1
0
        public ActionResult ReturnMonthDays(AjaxDateModel model)
        {
            CalendarViewModel calendar = new CalendarViewModel();
            AjaxDateModel     date     = new AjaxDateModel();

            date.year  = model.year;
            date.month = model.month;
            calendar   = getMonthDays(date);

            return(Json(new { calendar = calendar }, JsonRequestBehavior.DenyGet));
        }
Exemple #2
0
        public CalendarViewModel getMonthDays(AjaxDateModel model)
        {
            CalendarViewModel calendar = new CalendarViewModel();

            calendar.Vacations    = vacationrepo.GetVacations();
            calendar.BankHolidays = bankHolidayrepo.GetBankHolidays();

            var numberOfDays = DateTime.DaysInMonth(model.year, model.month);

            for (int i = 1; i <= numberOfDays; ++i)
            {
                var date = new DateTime(model.year, model.month, i);

                MonthDayViewModel day = new MonthDayViewModel();
                day.day       = i;
                day.nameOfDay = date.DayOfWeek.ToString();

                var holiday = calendar.BankHolidays.FirstOrDefault(x => x.Day == i && x.Month == model.month);

                if (holiday != null)
                {
                    day.isFreeDay   = true;
                    day.description = holiday.Description;
                }
                else
                {
                    if (day.nameOfDay == "Sunday" || day.nameOfDay == "Saturday")
                    {
                        day.isFreeDay   = true;
                        day.description = "Weekend";
                    }
                    else
                    {
                        day.isFreeDay   = false;
                        day.description = null;
                    }
                }

                calendar.MonthDays.Add(day);
            }

            return(calendar);
        }
Exemple #3
0
        public ActionResult Index()
        {
            var users = database.GetUsers();
            var teams = teamrep.GetTeams();

            var roles = databaseContext.Roles.ToList();

            DashboardViewModels dashboardVM = new DashboardViewModels();

            dashboardVM.UserList = users;
            dashboardVM.TeamList = teams;
            dashboardVM.Roles    = roles;

            CalendarViewModel calendar = new CalendarViewModel();
            AjaxDateModel     date     = new AjaxDateModel();

            date.year  = DateTime.Now.Year;
            date.month = DateTime.Now.Month;

            calendar = getMonthDays(date);

            dashboardVM.Calendar = calendar;
            return(View(dashboardVM));
        }