Example #1
0
        public ActionResult RosterContinue(VMRosterContinue vm)
        {
            VMLoggedUser  LoggedInUser = Session["LoggedInUser"] as VMLoggedUser;
            VMRosterModel vmRoster     = RosterService.ContinueRoster(vm);

            return(View("Create2", vmRoster));
        }
Example #2
0
        public void PostCreate2(VMRosterModel vm, List <RosterAttributes> rosterAttributeList)
        {
            List <RosterDetail> vmRosterDetail = new List <RosterDetail>();
            Expression <Func <RosterDetail, bool> > SpecificEntries = aa => aa.RosterDate >= vm.StartDate && aa.RosterDate <= vm.EndDate;

            vmRosterDetail = RosterDetailService.GetIndexSpecific(SpecificEntries);
            foreach (var rosterAttribute in rosterAttributeList)
            {
                //if (isRosterValueChanged(roster, _selectedShift))
                {
                    RosterDetail _RotaDetail = new RosterDetail();
                    _RotaDetail.CriteriaValueDate = "C" + vm.CriteriaValue.ToString() + rosterAttribute.DutyDate.ToString("yyMMdd");
                    //_RotaDetail.CompanyID = _selectedShift.CompanyID;
                    _RotaDetail.OpenShift   = false;
                    _RotaDetail.RosterAppID = vm.RotaAppID;
                    if (rosterAttribute.WorkMin == 0)
                    {
                        _RotaDetail.DutyCode = "R";
                    }
                    else
                    {
                        _RotaDetail.DutyCode = "D";
                    }

                    _RotaDetail.DutyTime   = rosterAttribute.DutyTime;
                    _RotaDetail.WorkMin    = (short)rosterAttribute.WorkMin;
                    _RotaDetail.RosterDate = rosterAttribute.DutyDate;
                    if (vmRosterDetail.Where(aa => aa.CriteriaValueDate == _RotaDetail.CriteriaValueDate).Count() == 0)
                    {
                        RosterDetailService.PostCreate(_RotaDetail);
                    }
                }
            }
        }
Example #3
0
        private VMRosterModel CalculateRosterFields(VMRosterApplication vm, int _RotaAppID)
        {
            VAT_Shift     shift     = DDService.GetShift().Where(aa => aa.PShiftID == vm.ShiftID).First();
            VMRosterModel _objmodel = new VMRosterModel();

            try
            {
                int endPoint = 0;
                if (vm.RosterTypeID == 2)
                {
                    endPoint = (vm.DateEnded.Value - vm.DateStarted.Value).Days + 1;
                }
                else if (vm.RosterTypeID == 3)
                {
                    endPoint = 15;
                }
                else if (vm.RosterTypeID == 4)
                {
                    endPoint = System.DateTime.DaysInMonth(vm.DateStarted.Value.Year, vm.DateEnded.Value.Month);
                }
                else if (vm.RosterTypeID == 4)
                {
                    endPoint = 84;
                }

                _objmodel._RosterAttributes = new List <RosterAttributes>();
                _objmodel.Criteria          = ConvertCriteriaAbrvToFull("C");
                _objmodel.RotaAppID         = _RotaAppID;
                _objmodel.CriteriaValue     = vm.CrewID;
                _objmodel.ShiftID           = vm.ShiftID;
                _objmodel.StartDate         = vm.DateStarted.Value;
                _objmodel.EndDate           = vm.DateEnded.Value;
                _objmodel.NoOfDays          = endPoint;
                _objmodel.CriteriaValueName = DDService.GetCrew().Where(aa => aa.PCrewID == vm.CrewID).First().CrewName;
                _objmodel.ShiftName         = shift.ShiftName;
                DateTime _StartDate = vm.DateStarted.Value;
                for (int i = 1; i <= endPoint; i++)
                {
                    string   _day  = _StartDate.Date.ToString("dddd");
                    string   _date = _StartDate.Date.ToString("dd-MMM-yyyy");
                    string   shiftStartTimeString = GetShiftStartTimeString(_StartDate.DayOfWeek, vm);
                    TimeSpan shiftStartTime       = ATAssistant.ConvertTime(shiftStartTimeString);
                    int      workMin = GetWorkMinutesForSpecificDates(_StartDate, vm);
                    _objmodel._RosterAttributes.Add(new RosterAttributes {
                        ID = i, DateString = _date, Day = _day, DutyDate = _StartDate.Date, DutyTimeString = shiftStartTimeString, DutyTime = shiftStartTime, WorkMin = workMin
                    });
                    _StartDate = _StartDate.AddDays(1);
                }
                Expression <Func <RosterApplication, bool> > SpecificEntries = c => c.RotaAppID == _RotaAppID;
                RosterApplication rosterApp = RosterApplicationService.GetIndexSpecific(SpecificEntries).First();
                rosterApp.DateEnded = _StartDate.AddDays(-1);
                RosterApplicationService.PostEdit(rosterApp);
                return(_objmodel);
            }
            catch (Exception ex)
            {
                return(_objmodel);
            }
        }
Example #4
0
        public ActionResult Create2(VMRosterModel vm)
        {
            List <RosterAttributes> rosterAttributeList = new List <RosterAttributes>();
            VAT_Shift _selectedShift = DDService.GetShift().Where(aa => aa.PShiftID == vm.ShiftID).First();
            int       _RotaAppID     = Convert.ToInt32(Request.Form["RotaAppID"].ToString());


            for (int i = 1; i <= vm.NoOfDays; i++)
            {
                rosterAttributeList.Add(new RosterAttributes()
                {
                    DutyTime = ATAssistant.ConvertTime(Request.Form["DT-" + i.ToString()].ToString()),
                    DutyDate = Convert.ToDateTime(Request.Form["Date-" + i.ToString()]),
                    WorkMin  = Convert.ToInt32(Request.Form["WM-" + i.ToString()])
                });
            }
            VMLoggedUser LoggedInUser = Session["LoggedInUser"] as VMLoggedUser;

            RosterService.PostCreate2(vm, rosterAttributeList);
            ViewBag.ErrorList = "";
            CreateHelper();
            return(RedirectToAction("Index"));
        }
Example #5
0
        public ActionResult Create1(VMRosterApplication obj)
        {
            List <string> ValidationError = new List <string>();
            // check for validation
            Expression <Func <RosterApplication, bool> > SpecificEntries = item => obj.DateStarted <item.DateEnded && item.DateEnded> item.DateStarted && item.CriteriaData == obj.CrewID;
            List <RosterApplication> tempVM = RosterApplicationService.GetIndexSpecific(SpecificEntries);

            if (tempVM.Count > 0)
            {
                ValidationError.Add("Rosters already created with same criteria");
            }
            if (ValidationError.Count == 0)
            {
                VMLoggedUser  LoggedInUser = Session["LoggedInUser"] as VMLoggedUser;
                VMRosterModel vm           = RosterService.PostCreate1(obj, LoggedInUser);
                return(View("Create2", vm));
            }
            else
            {
                ViewBag.ErrorList = ValidationError.ToList();
                CreateHelper();
                return(View("Create1", obj));
            }
        }
Example #6
0
        private VMRosterModel CalculateRosterEditEntries(RosterApplication rosterApp, List <RosterDetail> rosterDetails)
        {
            VAT_Shift     shift     = DDService.GetShift().Where(aa => aa.PShiftID == rosterApp.ShiftID).First();
            VMRosterModel _objmodel = new VMRosterModel();
            int           i         = 1;

            try
            {
                _objmodel._RosterAttributes = new List <RosterAttributes>();
                DateTime _StartDate = (DateTime)rosterApp.DateStarted;
                _objmodel.RotaAppID = rosterApp.RotaAppID;
                _objmodel.ShiftName = shift.ShiftName;
                switch (rosterApp.RosterCriteria)
                {
                case "S":

                    break;

                case "C":
                    _objmodel.CriteriaValueName = DDService.GetCrew().Where(aa => aa.PCrewID == rosterApp.CriteriaData).First().CrewName;
                    break;

                case "T":

                    break;

                case "employee":

                    break;
                }
                while (_StartDate <= rosterApp.DateEnded)
                {
                    string   _day      = _StartDate.Date.ToString("dddd");
                    string   _date     = _StartDate.Date.ToString("dd-MMM-yyyy");
                    string   _DTime    = "";
                    TimeSpan _DutyTime = new TimeSpan();
                    int      _WorkMin  = 0;
                    if (rosterDetails.Where(aa => aa.RosterDate == _StartDate).Count() > 0)
                    {
                        // from roster details
                        RosterDetail rotaDetail = rosterDetails.First(aa => aa.RosterDate == _StartDate);
                        _DTime    = rotaDetail.DutyTime.Value.Hours.ToString("00") + rotaDetail.DutyTime.Value.Minutes.ToString("00");
                        _WorkMin  = (int)rotaDetail.WorkMin;
                        _DutyTime = (TimeSpan)rotaDetail.DutyTime;
                    }
                    else
                    {
                        //from shift

                        _DTime    = shift.StartTime.Hours.ToString("00") + shift.StartTime.Minutes.ToString("00");
                        _WorkMin  = CalculateShiftWorkMins(_StartDate, shift);
                        _DutyTime = shift.StartTime;
                    }
                    _objmodel._RosterAttributes.Add(new RosterAttributes {
                        ID = i, DateString = _date, Day = _day, DutyDate = _StartDate.Date, DutyTimeString = _DTime, DutyTime = _DutyTime, WorkMin = _WorkMin
                    });
                    _StartDate = _StartDate.AddDays(1);
                    i++;
                }
                _objmodel.NoOfDays = i;
                return(_objmodel);
            }
            catch (Exception ex)
            {
                return(_objmodel);
            }
        }