コード例 #1
0
        public List <DisplayShiftVM> GetShiftsForWeek([FromBody] int week)
        {
            UserRepo uRepo = new UserRepo(context, service);

            List <DisplayShiftVM> schedule = new List <DisplayShiftVM>();

            var shifts = context.Schedule;

            if (shifts.Count() != 0)
            {
                foreach (var shift in shifts)
                {
                    if (shift.Week == week)
                    {
                        EmployeeVM     employee     = uRepo.GetEmployeeDetails(shift.EmpId);
                        DisplayShiftVM displayShift = new DisplayShiftVM
                        {
                            ShiftId   = shift.ShiftId,
                            Firstname = employee.Firstname,
                            Lastname  = employee.Lastname,
                            Week      = shift.Week,
                            Day       = shift.Day,
                            StartTime = shift.StartTime.ToString()
                        };
                        schedule.Add(displayShift);
                    }
                }
            }


            return(schedule);
        }
コード例 #2
0
        public List <DisplayShiftVM> GetDroppedShifts()
        {
            //var shifts = context.DroppedShifts.OrderBy(s => s.Week).ThenBy(s => s.Day);
            var shifts = from s in context.DroppedShifts
                         from u in context.UserDetails
                         where s.EmpId == u.EmpId
                         orderby s.Week, s.Day
                select new
            {
                ShiftId   = s.ShiftId,
                Firstname = u.Firstname,
                Lastname  = u.Lastname,
                Day       = s.Day,
                Week      = s.Week,
                StartTime = s.StartTime
            };

            List <DisplayShiftVM> theShifts = new List <DisplayShiftVM>();

            foreach (var shift in shifts)
            {
                DisplayShiftVM newShift = new DisplayShiftVM
                {
                    ShiftId   = shift.ShiftId,
                    Firstname = shift.Firstname,
                    Lastname  = shift.Lastname,
                    Day       = shift.Day,
                    Week      = shift.Week,
                    StartTime = shift.StartTime.ToString()
                };
                theShifts.Add(newShift);
            }
            return(theShifts);
        }
コード例 #3
0
        public List <DisplayShiftVM> GetShiftsPerEmployee(string email)
        {
            List <DisplayShiftVM> theShifts = new List <DisplayShiftVM>();

            //var user = context.Users.Where(u => u.Email == email).FirstOrDefault();
            //var shifts = context.Schedule.Where(s => s.EmpId == user.Email);

            var query = from u in context.Users
                        from s in context.Schedule
                        from ud in context.UserDetails
                        where u.Email == email
                        where u.Id == s.EmpId
                        where ud.EmpId == u.Id
                        select new
            {
                s.ShiftId,
                ud.Firstname,
                ud.Lastname,
                s.Day,
                s.Week,
                s.StartTime
            };

            foreach (var shift in query)
            {
                DisplayShiftVM addShift = new DisplayShiftVM
                {
                    ShiftId   = shift.ShiftId,
                    Firstname = shift.Firstname,
                    Lastname  = shift.Lastname,
                    Day       = shift.Day,
                    Week      = shift.Week,
                    StartTime = shift.StartTime.ToString()
                };
                theShifts.Add(addShift);
            }
            return(theShifts);
        }