Ejemplo n.º 1
0
        public ActionResult ShiftCreateClose(ShiftDetailViewModel data)
        {
            ShiftDetailViewModel sdvm = new ShiftDetailViewModel();

            if (!ModelState.IsValid)
            {
                return(View("Shift/Create", sdvm));
            }
            ShiftDTO res = new ShiftDTO();

            res.ShiftName       = data.ShiftName;
            res.ShiftDelayAllow = data.ShiftDelayAllow;
            res.ShiftStatus     = data.ShiftStatus;
            ShiftDTO    result = _shifService.InsertShift(res);
            ShiftDayDTO detail = new ShiftDayDTO();

            foreach (var item in data.ShiftDay)
            {
                detail.DayNumber    = item.DayNumber + 1;
                detail.DayName      = item.DayName;
                detail.DayShiftId   = result.ShiftId;
                detail.DayStartTime = item.DayStartTime;
                detail.DayEndTime   = item.DayEndTime;
                detail.DayWeekend   = item.DayWeekend;
                TimeSpan a = item.DayEndTime.Value.Subtract(item.DayStartTime.Value);
                double   b = a.TotalMinutes;
                detail.DayWorkingMinute = Convert.ToInt32(b);
                ShiftDayDTO resultDetail = _shiftDayService.InsertShiftDayDetail(detail);
                ViewBag.Success = "New Office Type created successfully";
            }
            ViewBag.Success = "Shift " + result.ShiftName + " has been created";
            return(RedirectToAction("Shift"));
        }
Ejemplo n.º 2
0
        public IActionResult GenerateSchedule(string month, string VoorkeurLeden)
        {
            List <MemberDTO> members = memberRetRepository.GetAll();

            ShiftViewModel shiftViewModel = new ShiftViewModel();

            List <ShiftDTO> membershifts = shiftRetRepository.GetAllShiftsForClub(month);

            foreach (ShiftDTO shift in membershifts)
            {
                scheduleSaveRepository.Shifts.Add(shift);

                scheduleSaveRepository.PlanShifts(members, VoorkeurLeden);
            }

            foreach (ShiftDTO shiftmember in scheduleSaveRepository.Shifts)
            {
                ShiftDetailViewModel model = new ShiftDetailViewModel();

                model.EndMoment   = shiftmember.EndMoment;
                model.StartMoment = shiftmember.StartMoment;
                model.Members     = shiftmember.Members;
                model.ID          = shiftmember.ID;

                shiftViewModel.Shifts.Add(model);
            }

            return(View(shiftViewModel));
        }
Ejemplo n.º 3
0
        public ActionResult ShiftEdit(int id)
        {
            ShiftDetailViewModel resById          = new ShiftDetailViewModel();
            ShiftDTO             getParentDetails = _shifService.GetShiftById(id);

            resById.ShiftId         = getParentDetails.ShiftId;
            resById.ShiftName       = getParentDetails.ShiftName;
            resById.ShiftDelayAllow = getParentDetails.ShiftDelayAllow;
            resById.ShiftStatus     = getParentDetails.ShiftStatus;
            List <ShiftDayDTO> getDetails = _shiftDayService.GetShiftByParentId(getParentDetails.ShiftId);

            resById.ShiftDay = getDetails;
            return(View(resById));
        }
Ejemplo n.º 4
0
        public IActionResult Edit(int id)
        {
            ShiftDTO shift = this.shiftRetRepository.GetByID(id);

            ShiftDetailViewModel model = new ShiftDetailViewModel()
            {
                ID             = shift.ID,
                Name           = shift.Name,
                StartMoment    = shift.StartMoment,
                EndMoment      = shift.EndMoment,
                EventType      = shift.EventType,
                MaxMemberCount = shift.MaxMemberCount
            };

            return(View(model));
        }
Ejemplo n.º 5
0
        public IActionResult Edit(ShiftDetailViewModel Model)
        {
            ShiftDTO shift = new ShiftDTO()
            {
                ID             = Model.ID,
                Name           = Model.Name,
                StartMoment    = Model.StartMoment,
                EndMoment      = Model.EndMoment,
                EventType      = Model.EventType,
                MaxMemberCount = Model.MaxMemberCount,
                Members        = Model.Members
            };

            shiftSaveRepository.UpdateShift(shift);
            // Create dto from model
            // Save model to database

            return(RedirectToAction("GenerateSchedule"));
        }
Ejemplo n.º 6
0
        public ActionResult ShiftEdit(ShiftDetailViewModel data)
        {
            ShiftDetailViewModel sdvm = new ShiftDetailViewModel();
            //if (!ModelState.IsValid)
            //{
            //    return View("Shift/Edit", sdvm);
            //}
            ShiftDTO res = new ShiftDTO();

            res.ShiftId         = data.ShiftId;
            res.ShiftName       = data.ShiftName;
            res.ShiftDelayAllow = data.ShiftDelayAllow;
            res.ShiftStatus     = data.ShiftStatus;
            int         result = _shifService.UpdateShift(res);
            ShiftDayDTO detail = new ShiftDayDTO();

            if (result > 0)
            {
                foreach (var item in data.ShiftDay)
                {
                    detail.DayId        = item.DayId;
                    detail.DayNumber    = item.DayNumber + 1;
                    detail.DayName      = item.DayName;
                    detail.DayShiftId   = item.DayShiftId;
                    detail.DayStartTime = item.DayStartTime;
                    detail.DayEndTime   = item.DayEndTime;
                    detail.DayWeekend   = item.DayWeekend;
                    TimeSpan a = item.DayEndTime.Value.Subtract(item.DayStartTime.Value);
                    double   b = a.TotalMinutes;
                    detail.DayWorkingMinute = Convert.ToInt32(b);
                    int resultDetail = _shiftDayService.UpdateShiftDetail(detail);
                }
            }

            return(RedirectToAction("Shift", "Shift"));
        }