Beispiel #1
0
        public List <Trade> GetAll(int userId)
        {
            Roster roster = rost.GetRoster(userId);
            var    trades = _db.Trades.Include("Shift").Include("ReworkShift").Include("RequestUser").Include("AcceptUser").Where(t => t.AcceptUserId == null)
                            .ToList();
            List <Trade> result = new List <Trade>();

            foreach (EFTrade trade in trades)
            {
                foreach (Shift shift in roster.Shifts)
                {
                    //I should not work on the day he wants me to work.
                    //I should work on the day he wants to work back
                    if (trade.Shift.ShiftId != shift.ShiftId && trade.ReworkShift.ShiftId == shift.ShiftId)
                    {
                        Trade newTrade = Converter.ToTrade(trade);
                        result.Add(newTrade);
                    }
                    else
                    {
                        //nothing cabron
                    }
                }
            }
            return(result);
        }
Beispiel #2
0
        public List <Shift> GetAllFree(int userId)
        {
            var          shifts = _db.Shifts.ToList();
            Roster       roster = rost.GetRoster(userId);
            List <Shift> result = new List <Shift>();

            foreach (EFShift shift in shifts.ToList())
            {
                foreach (Shift shif in roster.Shifts)
                {
                    if (shif.ShiftId == shift.ShiftId)
                    {
                        //nothing cabron
                        shifts.Remove(shift);
                    }
                }
            }

            foreach (EFShift shift in shifts.ToList())
            {
                result.Add(Converter.ToShift(shift));
            }
            return(result);
        }