Example #1
0
        public List <DescAndID> GetDescription(DateTime date, int teamID)
        {
            List <DescAndID> list = new List <DescAndID>();

            var dateData = GetBusies(teamID);
            var dates    = new List <DateTime>();

            foreach (var item in dateData)
            {
                dates.Add(item.Day);
            }

            using (var ctx = new ApplicationDbContext())
            {
                foreach (BusyDay day in ctx.BusyDays.ToList())
                {
                    if (date >= day.Busy && date <= day.BusyEnd)
                    {
                        foreach (var data in dateData)
                        {
                            if (date == data.Day && !list.Contains(new DescAndID {
                                Description = data.Description, ID = day.BusyDayID
                            }))
                            {
                                DescAndID item = new DescAndID
                                {
                                    Description = data.Description,
                                    ID          = data.ID,
                                    UserName    = GetUserName(data.UserName)
                                };
                                list.Add(item);
                            }
                        }
                        break;
                    }
                }

                return(list);
            }
        }
        public List <DescAndID> GetDescription(DateTime date, List <BusyData> busies)
        {
            List <DescAndID> list = new List <DescAndID>();

            var dates = new List <DateTime>();

            foreach (var item in busies)
            {
                dates.Add(item.Day);
            }

            using (var ctx = new ApplicationDbContext())
            {
                foreach (BusyDay day in ctx.BusyDays.ToList())
                {
                    if (date >= day.Busy && date <= day.BusyEnd && day.UserID == _userID)
                    {
                        foreach (var data in busies)
                        {
                            if (date == data.Day && !list.Contains(new DescAndID {
                                Description = data.Description, ID = day.BusyDayID
                            }))
                            {
                                DescAndID item = new DescAndID
                                {
                                    Description = data.Description,
                                    ID          = data.ID
                                };
                                list.Add(item);
                            }
                        }
                        break;
                    }
                }

                return(list);
            }
        }