Esempio n. 1
0
        public async Task <ActionResult <List <CalendarItem> > > GetDepartmentCalendarItems()
        {
            List <CalendarItem>       jsonItems = new List <CalendarItem>();
            List <Model.CalendarItem> items     = null;

            items = await _calendarService.GetAllCalendarItemsForDepartmentAsync(DepartmentId);

            var department = await _departmentsService.GetDepartmentByIdAsync(DepartmentId, false);

            foreach (var item in items)
            {
                CalendarItem calendarItem = new CalendarItem();
                calendarItem.CalendarItemId      = item.CalendarItemId;
                calendarItem.Title               = item.Title;
                calendarItem.Start               = item.Start.TimeConverter(department);
                calendarItem.End                 = item.End.TimeConverter(department);
                calendarItem.StartTimezone       = item.StartTimezone;
                calendarItem.EndTimezone         = item.EndTimezone;
                calendarItem.Description         = item.Description;
                calendarItem.RecurrenceId        = item.RecurrenceId;
                calendarItem.RecurrenceRule      = item.RecurrenceRule;
                calendarItem.RecurrenceException = item.RecurrenceException;
                calendarItem.IsAllDay            = item.IsAllDay;
                calendarItem.ItemType            = item.ItemType;
                calendarItem.Location            = item.Location;
                calendarItem.SignupType          = item.SignupType;
                calendarItem.Reminder            = item.Reminder;
                calendarItem.LockEditing         = item.LockEditing;
                calendarItem.Entities            = item.Entities;
                calendarItem.RequiredAttendes    = item.RequiredAttendes;
                calendarItem.OptionalAttendes    = item.OptionalAttendes;

                if (!String.IsNullOrWhiteSpace(item.CreatorUserId))
                {
                    calendarItem.CreatorUserId = item.CreatorUserId.ToString();
                }

                if (department.IsUserAnAdmin(UserId))
                {
                    calendarItem.IsAdminOrCreator = true;
                }
                else if (!String.IsNullOrWhiteSpace(item.CreatorUserId) && item.CreatorUserId == UserId)
                {
                    calendarItem.IsAdminOrCreator = true;
                }
                else
                {
                    calendarItem.IsAdminOrCreator = false;
                }


                jsonItems.Add(calendarItem);
            }

            return(Ok(jsonItems));
        }
Esempio n. 2
0
        public List <CalendarItem> GetDepartmentCalendarItemsInRange(DateTime start, DateTime end)
        {
            List <CalendarItem>       jsonItems = new List <CalendarItem>();
            List <Model.CalendarItem> items     = null;

            items = _calendarService.GetAllCalendarItemsForDepartmentInRange(DepartmentId, start.SetToMidnight(), end.SetToEndOfDay());
            var department = _departmentsService.GetDepartmentById(DepartmentId, false);

            foreach (var item in items)
            {
                CalendarItem calendarItem = new CalendarItem();
                calendarItem.CalendarItemId      = item.CalendarItemId;
                calendarItem.Title               = item.Title;
                calendarItem.Start               = item.Start.TimeConverter(department);
                calendarItem.End                 = item.End.TimeConverter(department);
                calendarItem.StartTimezone       = item.StartTimezone;
                calendarItem.EndTimezone         = item.EndTimezone;
                calendarItem.Description         = item.Description;
                calendarItem.RecurrenceId        = item.RecurrenceId;
                calendarItem.RecurrenceRule      = item.RecurrenceRule;
                calendarItem.RecurrenceException = item.RecurrenceException;
                calendarItem.IsAllDay            = item.IsAllDay;
                calendarItem.ItemType            = item.ItemType;
                calendarItem.Location            = item.Location;
                calendarItem.SignupType          = item.SignupType;
                calendarItem.Reminder            = item.Reminder;
                calendarItem.LockEditing         = item.LockEditing;
                calendarItem.Entities            = item.Entities;
                calendarItem.RequiredAttendes    = item.RequiredAttendes;
                calendarItem.OptionalAttendes    = item.OptionalAttendes;

                if (!String.IsNullOrWhiteSpace(item.CreatorUserId))
                {
                    calendarItem.CreatorUserId = item.CreatorUserId.ToString();
                }

                if (department.IsUserAnAdmin(UserId))
                {
                    calendarItem.IsAdminOrCreator = true;
                }
                else if (!String.IsNullOrWhiteSpace(item.CreatorUserId) && item.CreatorUserId == UserId)
                {
                    calendarItem.IsAdminOrCreator = true;
                }
                else
                {
                    calendarItem.IsAdminOrCreator = false;
                }


                jsonItems.Add(calendarItem);
            }

            return(jsonItems);
        }
Esempio n. 3
0
        public CalendarItem GetCalendarItem(int id)
        {
            var calendarItem = new CalendarItem();
            var item         = _calendarService.GetCalendarItemById(id);
            var department   = _departmentsService.GetDepartmentById(DepartmentId, false);

            calendarItem.CalendarItemId      = item.CalendarItemId;
            calendarItem.Title               = item.Title;
            calendarItem.Start               = item.Start.TimeConverter(department);
            calendarItem.End                 = item.End.TimeConverter(department);
            calendarItem.StartTimezone       = item.StartTimezone;
            calendarItem.EndTimezone         = item.EndTimezone;
            calendarItem.Description         = item.Description;
            calendarItem.RecurrenceId        = item.RecurrenceId;
            calendarItem.RecurrenceRule      = item.RecurrenceRule;
            calendarItem.RecurrenceException = item.RecurrenceException;
            calendarItem.IsAllDay            = item.IsAllDay;
            calendarItem.ItemType            = item.ItemType;
            calendarItem.Location            = item.Location;
            calendarItem.SignupType          = item.SignupType;
            calendarItem.Reminder            = item.Reminder;
            calendarItem.LockEditing         = item.LockEditing;
            calendarItem.Entities            = item.Entities;
            calendarItem.RequiredAttendes    = item.RequiredAttendes;
            calendarItem.OptionalAttendes    = item.OptionalAttendes;

            if (!String.IsNullOrWhiteSpace(item.CreatorUserId))
            {
                calendarItem.CreatorUserId = item.CreatorUserId.ToString();
            }

            if (department.IsUserAnAdmin(UserId))
            {
                calendarItem.IsAdminOrCreator = true;
            }
            else if (!String.IsNullOrWhiteSpace(item.CreatorUserId) && item.CreatorUserId == UserId)
            {
                calendarItem.IsAdminOrCreator = true;
            }
            else
            {
                calendarItem.IsAdminOrCreator = false;
            }

            if (item.Attendees == null || !item.Attendees.Any())
            {
                calendarItem.Attending = false;
            }
            else
            {
                calendarItem.Attending = item.Attendees.Any(x => x.UserId == UserId);
                calendarItem.Attendees = new List <CalendarItemAttendee>();

                foreach (var attendee in item.Attendees)
                {
                    CalendarItemAttendee attend = new CalendarItemAttendee();
                    attend.CalendarItemId = attendee.CalendarItemId;
                    attend.UserId         = attendee.UserId;
                    attend.AttendeeType   = attendee.AttendeeType;
                    attend.Note           = attendee.Note;

                    calendarItem.Attendees.Add(attend);
                }
            }

            return(calendarItem);
        }
Esempio n. 4
0
        public async Task <ActionResult <List <CalendarItem> > > GetAllDepartmentCalendarItemsInRange(string startDate, string endDate)
        {
            List <CalendarItem>       jsonItems = new List <CalendarItem>();
            List <Model.CalendarItem> items     = null;

            var startDateString = HttpUtility.UrlDecode(startDate);
            var endDateString   = HttpUtility.UrlDecode(endDate);

            var start = DateTime.ParseExact(startDateString, "MM/dd/yyyy HH:mm:ss zzz", CultureInfo.InvariantCulture);
            var end   = DateTime.ParseExact(endDateString, "MM/dd/yyyy HH:mm:ss zzz", CultureInfo.InvariantCulture);

            items = await _calendarService.GetAllCalendarItemsForDepartmentInRangeAsync(DepartmentId, start.SetToMidnight(), end.SetToEndOfDay());

            var department = await _departmentsService.GetDepartmentByIdAsync(DepartmentId, false);

            foreach (var item in items)
            {
                CalendarItem calendarItem = new CalendarItem();
                calendarItem.CalendarItemId      = item.CalendarItemId;
                calendarItem.Title               = item.Title;
                calendarItem.Start               = item.Start.TimeConverter(department);
                calendarItem.End                 = item.End.TimeConverter(department);
                calendarItem.StartTimezone       = item.StartTimezone;
                calendarItem.EndTimezone         = item.EndTimezone;
                calendarItem.Description         = item.Description;
                calendarItem.RecurrenceId        = item.RecurrenceId;
                calendarItem.RecurrenceRule      = item.RecurrenceRule;
                calendarItem.RecurrenceException = item.RecurrenceException;
                calendarItem.IsAllDay            = item.IsAllDay;
                calendarItem.ItemType            = item.ItemType;
                calendarItem.Location            = item.Location;
                calendarItem.SignupType          = item.SignupType;
                calendarItem.Reminder            = item.Reminder;
                calendarItem.LockEditing         = item.LockEditing;
                calendarItem.Entities            = item.Entities;
                calendarItem.RequiredAttendes    = item.RequiredAttendes;
                calendarItem.OptionalAttendes    = item.OptionalAttendes;

                if (!String.IsNullOrWhiteSpace(item.CreatorUserId))
                {
                    calendarItem.CreatorUserId = item.CreatorUserId.ToString();
                }

                if (department.IsUserAnAdmin(UserId))
                {
                    calendarItem.IsAdminOrCreator = true;
                }
                else if (!String.IsNullOrWhiteSpace(item.CreatorUserId) && item.CreatorUserId == UserId)
                {
                    calendarItem.IsAdminOrCreator = true;
                }
                else
                {
                    calendarItem.IsAdminOrCreator = false;
                }


                jsonItems.Add(calendarItem);
            }

            return(Ok(jsonItems));
        }