Ejemplo n.º 1
0
        public async Task <JsonResult> Events(DateTime start, DateTime end)
        {
            var events = new List <ResEvent>();

            var user = await _userRepository.GetUser(User.Identity.Name);

            if (user != null)
            {
                var eventsCalendar = await _calendarEventRepository.GetByUser(start, end, user.Id);

                foreach (var ev in eventsCalendar)
                {
                    events.Add(new ResEvent
                    {
                        id    = ev.Id.ToString(),
                        title = ev.Title,
                        start = ev.StartDate,
                        end   = ev.EndDate,
                        color = "#62cb31"
                    });
                }
                eventsCalendar = await _calendarEventRepository.GetByUser(start, end, ObjectId.Parse(user.CurrentOrganisation));

                foreach (var ev in eventsCalendar)
                {
                    events.Add(new ResEvent
                    {
                        id    = ev.Id.ToString(),
                        title = ev.Title,
                        start = ev.StartDate,
                        end   = ev.EndDate,
                        color = "#3498db"
                    });
                }

                return(Json(events, JsonRequestBehavior.AllowGet));
            }

            events.Add(new ResEvent
            {
                title = "test",
                start = new DateTime(2017, 11, 2, 14, 23, 0)
            });
            return(Json(events, JsonRequestBehavior.AllowGet));
        }