Beispiel #1
0
        public CalendarModel generateCalendar(YearMonthModel ymmodel)//, string userID)
        {
            //create a new calendar model
            CalendarModel newCalendar = new CalendarModel();

            //get bankholidays, vacations and populate calendar
            var bankholidays = BhR.GetBankHolidays();
            var vacations    = Vacations.GetVacations();

            newCalendar.monthdays    = new System.Collections.Generic.List <DayModel>();
            newCalendar.bankholidays = bankholidays;
            newCalendar.vacations    = vacations;

            //get our month days number and parse it
            var mdays = DateTime.DaysInMonth(ymmodel.year, ymmodel.month);

            for (var iter = 1; iter <= mdays; iter++)
            {
                //default values for descriptions and freeday
                var descriptionStatus = "busy";
                var isFreeDayStatus   = false;

                //next day and check if its weekend, bankholiday or vacation day
                var currentDate = new DateTime(ymmodel.year, ymmodel.month, iter);
                if ((currentDate.DayOfWeek == DayOfWeek.Saturday) || (currentDate.DayOfWeek == DayOfWeek.Sunday))
                {
                    descriptionStatus = "Weekend";
                    isFreeDayStatus   = true;
                }
                if (bankholidays.Any(x => x.Month == currentDate.Month && x.Day == iter))
                {
                    isFreeDayStatus    = true;
                    descriptionStatus += " BankHoliday";
                }
                var CurrentUserID = User.Identity.GetUserId();
                var check         = newdb.UserDetails.FirstOrDefault(d => d.UserID == CurrentUserID);
                if (vacations.Any(x => x.UserId == check.ID && x.StartDate <= currentDate && x.EndDate >= currentDate && x.StateId == 1))
                {
                    descriptionStatus += " Want to go to Vacation";
                }
                if (vacations.Any(x => x.UserId == check.ID && x.StartDate <= currentDate && x.EndDate >= currentDate && x.StateId == 2))
                {
                    isFreeDayStatus    = true;
                    descriptionStatus += " Vacation";
                }



                //add it to our list
                newCalendar.monthdays.Add(new DayModel {
                    description = descriptionStatus,
                    day         = iter,
                    name        = currentDate.ToString("dddd"),
                    isFreeDay   = isFreeDayStatus
                });
            }

            //return our calendar
            return(newCalendar);
        }
        // GET: Dashboard
        public ActionResult Index()
        {
            DashboardViewModel dashboardVM = new DashboardViewModel()
            {
                Test = "Test Value"
            };

            dashboardVM.UsersList = UserDetailsRepo.GetUsers();

            //////////////////////////////////////
            dashboardVM.Teams = TeamRepo.GetTeams();



            dashboardVM.CalendarViewModel.BankHolidays = BankHolidayRepo.GetBankHolidays();

            dashboardVM.CalendarViewModel.Vacations = VacationRepo.GetVacations();
            dashboardVM.CalendarViewModel.MonthDays = new List <MonthDaysViewModel>();
            //dashboardVM.CalendarViewModel.MonthDays.Day =
            for (int i = 1; i <= DateTime.DaysInMonth(2017, 7); i++)
            {
                DateTime dt  = new DateTime(2017, 7, i);
                string   aux = dt.DayOfWeek.ToString();
                dashboardVM.CalendarViewModel.MonthDays.Add(new MonthDaysViewModel(i, false, aux));
            }//ajax call from javascript

            //////////////////////////////////////
            //dashboardVM.Test = dashboardVM.UsersList[0].FirstName;
            return(View("Index", dashboardVM));
        }
        // GET: Dashboard
        public ActionResult Index()
        {
            var DbUsers = db.UserDetailsModel.ToList();
            DashboardViewModels dashboardVM = new DashboardViewModels();

            UserDetailsRepository UDR = new UserDetailsRepository();

            dashboardVM.UserList = UDR.GetUsers();

            TeamRepository TR = new TeamRepository();

            dashboardVM.TeamList = TR.GetTeams();

            List <IdentityRole> roles = db.Roles.ToList();

            dashboardVM.RoleList = roles;

            VacationRepository    vac  = new VacationRepository();
            BankHolidayRepository bank = new BankHolidayRepository();

            CalendarViewModel calendar = new CalendarViewModel();

            calendar.BankHolidayList = bank.GetBankHolidays();
            calendar.VacationList    = vac.GetVacations();

            dashboardVM.Calendar = calendar;
            return(View(dashboardVM));
        }
        private List <MonthDayViewModel> GetMonthDays(int year, int month)
        {
            List <MonthDayViewModel> days = new List <MonthDayViewModel>();

            var bankHolidays = getBankHoliday.GetBankHolidays();;

            DateTime now = DateTime.Now;

            int countOfDays = DateTime.DaysInMonth(year, month);

            var holidays = vacRep.GetVacations();

            for (int i = 1; i <= countOfDays; i++)
            {
                DateTime          date = new DateTime(year, month, i);
                MonthDayViewModel day  = new MonthDayViewModel();
                day.Day  = i;
                day.Name = date.DayOfWeek.ToString();

                var bH = bankHolidays.FirstOrDefault(x => x.Day == i && x.Month == month);

                day.IsFreeDay = date.DayOfWeek == DayOfWeek.Saturday || date.DayOfWeek == DayOfWeek.Sunday || bH != null;

                day.Vacations   = holidays.Where(x => DateTime.Compare(x.StartDate, date) <= 0 && DateTime.Compare(x.EndDate, date) >= 0).ToList();
                day.Description = date.ToString("MMMM");
                DateTimeFormatInfo mfi = new DateTimeFormatInfo();
                day.Month = mfi.GetMonthName(month).ToString();

                days.Add(day);
            }

            return(days);
        }
        // GET: Dashboard
        public ActionResult Index()
        {
            var users = database.GetUsers();
            var teams = db.GetTeams();
            var roles = newdb.Roles.ToList();

            DashboardViewModel dash = new DashboardViewModel()
            {
                UserList = users,
                TeamList = teams,
                Roles    = roles
            };
            CalendarViewModel Calendar = new CalendarViewModel()
            {
                BankHolidays = bank.GetBankHolidays(),
                Vacations    = vakacio.GetVacations()
            };
            VacationRepository vakrep = new VacationRepository();
            var datum = DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month);
            var free  = vakrep.GetVacations();

            for (int i = 1; i <= datum; ++i)
            {
                var date = new DateTime(DateTime.Now.Year, DateTime.Now.Month, i);

                bool isFreeDay = date.DayOfWeek == DayOfWeek.Saturday || date.DayOfWeek == DayOfWeek.Sunday;

                MonthDayViewModel day = new MonthDayViewModel()
                {
                    Day       = i,
                    Name      = date.DayOfWeek.ToString(),
                    IsFreeDay = isFreeDay
                };

                var vakacio = Calendar.BankHolidays.FirstOrDefault(x => x.Day == i && x.Month == DateTime.Now.Month);
                day.IsFreeDay = date.DayOfWeek == DayOfWeek.Saturday || date.DayOfWeek == DayOfWeek.Sunday || vakacio != null;
                day.Vacations = free.Where(x => DateTime.Compare(x.StartDate, date) <= 0 || DateTime.Compare(x.EndDate, date) >= 0).ToList();



                Calendar.MonthDays.Add(day);
            }
            ;
            dash.Calendar = Calendar;
            return(View(dash));
        }
Beispiel #6
0
        private List <Vacation> CreateVacationList()
        {
            List <Vacation> vacationlist       = new List <Vacation> {
            };
            VacationRepository       vacations = new VacationRepository();
            HolidayManagementContext database  = new HolidayManagementContext();
            var vac = vacations.GetVacations();

            foreach (var v in vac)
            {
                if (v.StateId == 1 || v.StateId == 4)
                {
                    vacationlist.Add(v);
                }
            }

            return(vacationlist);
        }
Beispiel #7
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);
        }
 public IActionResult getVacations()
 {
     return(Ok(vacationRepository.GetVacations()));
 }