コード例 #1
0
        public JsonResult GetEvents()
        {
            int vacationsCount = Vacationrepository.Count();


            var                  events    = new List <CalendarEventy>();
            List <Vacation>      vacations = new List <Vacation>();
            IEnumerable <Person> people    = PersonRepository.IncludeGet(p => p.Team);
            var                  colors    = GetColors(people.Count());
            int                  i         = 0;

            foreach (Person person in people)
            {
                vacations = Vacationrepository.Get(p => p.Peopleid == person.Id).ToList();

                DateTime start;
                DateTime end;
                var      viewModel = new CalendarEventy();



                foreach (Vacation vacation in vacations)
                {
                    start = vacation.FirstDate;
                    end   = vacation.SecontDate;
                    events.Add(new CalendarEventy()
                    {
                        Id     = vacation.Id,
                        allDay = true,
                        title  = "Vacation" + " " + person.LastName + " " + person.Name + " " + person.Team.TeamName,
                        start  = start.ToString("yyyy-MM-dd"),
                        end    = end.ToString("yyyy-MM-dd"),

                        backgroundColor = vacation.ConfirmedVacation ? colors[i] : "red"
                    });
                }
                i++;
            }
            return(Json(events.ToArray()));
        }
コード例 #2
0
        public JsonResult GetEvents(Guid PersonId)
        {
            IEnumerable <Vacation> vacations = Vacationrepository.Get(p => p.Peopleid == PersonId);
            DateTime start;
            DateTime end;
            var      viewModel = new CalendarEventy();
            var      events    = new List <CalendarEventy>();
            int      numColors = 10;
            var      colors    = new List <string>();

            for (int j = 0; j < numColors; j++)
            {
                var random = new Random(); // Don't put this here!
                colors.Add(String.Format("#{0:X6}", random.Next(0x1000000)));
            }
            int i = 1;

            foreach (Vacation vacation in vacations)
            {
                start = vacation.FirstDate;
                end   = vacation.SecontDate;
                events.Add(new CalendarEventy()
                {
                    Id              = Guid.NewGuid(),
                    title           = "Vacation" + i,
                    start           = start.ToString("yyyy-MM-dd"),
                    end             = end.ToString("yyyy-MM-dd"),
                    allDay          = false,
                    backgroundColor = colors[i]
                });
                i++;
            }


            return(Json(events.ToArray()));
        }