Ejemplo n.º 1
0
 public HomeController(
     ISchedulerWorkData schedulerWorkData,
     IMapper mapper,
     IScheduleSevice scheduleSevice,
     IEventsFactory eventsFactory)
     : base(schedulerWorkData, mapper, eventsFactory)
 {
     this.ScheduleSevice = scheduleSevice;
     this.ScheduleSevice.SchedulerWorkData = schedulerWorkData;
 }
Ejemplo n.º 2
0
        public async static Task <ScheduleViewModel> ReBuildForEditAsync(
            ScheduleViewModel model,
            IScheduleSevice services)
        {
            model.ProjectOptions = await services.GetShdeduleProjectOptions();

            model.ScheduleOptions = services.GetScheduleOptions();

            return(model);
        }
Ejemplo n.º 3
0
        public async static Task <IEnumerable <ScheduleViewModel> > ReBuildCollectionForEditAsync(
            IEnumerable <ScheduleViewModel> models,
            IScheduleSevice services)
        {
            var projectOptions = await services.GetShdeduleProjectOptions();

            var scheduleOptions = services.GetScheduleOptions();

            models.ToList().ForEach(x =>
                                    { x.ProjectOptions = projectOptions; x.ScheduleOptions = scheduleOptions; });

            return(models);
        }
Ejemplo n.º 4
0
        public async static Task <ScheduleViewModel> CreateForEditAsync(
            Schedule schedule,
            IScheduleSevice services,
            IMapper mapper)
        {
            var model = mapper.Map <Schedule, ScheduleViewModel>(schedule);

            model.ProjectOptions = await services.GetShdeduleProjectOptions();

            model.ScheduleOptions = services.GetScheduleOptions();

            return(model);
        }
Ejemplo n.º 5
0
        public async static Task <EmployeesShcedulerViewModel> ReBuildAsync(
            EmployeesShcedulerViewModel model,
            IScheduleSevice services,
            IMapper mapper)
        {
            var newModel = await EmployeesShcedulerViewModel.CreateAsync(services, mapper);

            model.Employees = newModel.Employees;
            model.LastScheduledEmployees = newModel.LastScheduledEmployees;
            model.IsTodayScheduleCreated = newModel.IsTodayScheduleCreated;
            model.Today = newModel.Today;

            return(model);
        }
Ejemplo n.º 6
0
        public async static Task <IEnumerable <ScheduleViewModel> > CreateCollectionForEditAsync(
            IEnumerable <Schedule> schedules,
            IScheduleSevice services,
            IMapper mapper)
        {
            var scheduleModels = mapper.Map <IEnumerable <Schedule>, IEnumerable <ScheduleViewModel> >(schedules);
            var projectOptions = await services.GetShdeduleProjectOptions();

            var scheduleOptions = services.GetScheduleOptions();

            scheduleModels.ToList().ForEach(x =>
                                            { x.ProjectOptions = projectOptions; x.ScheduleOptions = scheduleOptions; });

            return(scheduleModels);
        }
Ejemplo n.º 7
0
 public async static Task <SearchViewModel> Create(
     IScheduleSevice services,
     IMapper mapper)
 {
     return(new SearchViewModel()
     {
         // Giving some start values for the SearchModel dates.
         To = DateTime.Now,
         From = DateTime.Now.AddDays(-7),
         ProjectOptions = await services.GetShdeduleProjectOptions(),
         ScheduleOptions = services.GetScheduleOptions(),
         EmployeeOptions = await services.GetShdeduleEmployeeOptions(),
         Employees = new HashSet <EmployeeViewModel>()
     });
 }
Ejemplo n.º 8
0
        public async static Task <SearchViewModel> ReBuild(
            SearchViewModel model,
            IScheduleSevice services,
            IMapper mapper)
        {
            model.To             = DateTime.Now;
            model.From           = model.To.AddDays(-7);
            model.ProjectOptions = await services.GetShdeduleProjectOptions();

            model.ScheduleOptions = services.GetScheduleOptions();
            model.EmployeeOptions = await services.GetShdeduleEmployeeOptions();

            model.Employees = new HashSet <EmployeeViewModel>();

            return(model);
        }
Ejemplo n.º 9
0
 public async static Task <SearchViewModel> Create(
     IScheduleSevice services,
     IMapper mapper,
     IEnumerable <EmployeeViewModel> employees)
 {
     return(new SearchViewModel()
     {
         // Giving some start values for the SearchModel dates.
         To = DateTime.Now,
         From = DateTime.Now.AddDays(-7),
         ProjectOptions = await services.GetShdeduleProjectOptions(),
         ScheduleOptions = services.GetScheduleOptions(),
         EmployeeOptions = await services.GetShdeduleEmployeeOptions(),
         Employees = employees.Where(e => e.Schedules != null && e.Schedules.Count() > 0)
     });
 }
Ejemplo n.º 10
0
        public async static Task <EmployeesShcedulerViewModel> CreateAsync(
            IScheduleSevice services,
            IMapper mapper)
        {
            var employeesQuery = await services.SchedulerWorkData.Employees.FindAsync(x => !x.IsFired, i => i.Include(s => s.Schedules));

            var lastScheduledEmployees = services.FindEmployeeSchedules(employeesQuery);
            var employees = mapper.Map <IEnumerable <Employee>, IEnumerable <EmployeeViewModel> >(employeesQuery);
            await services.SetupEmployeeNewSchedule(employees);

            bool isTodayShceduleCreated = employees.Any(e => e.Schedules.Any(s => s.Date.Date == DateTime.Today));


            return(new EmployeesShcedulerViewModel()
            {
                LastScheduledEmployees = lastScheduledEmployees,
                Employees = employees,
                IsTodayScheduleCreated = isTodayShceduleCreated,
                Today = DateTime.Now.ToString(Constants.DateTimeFormats.Short)
            });
        }