示例#1
0
 public GetEventsResponse GetMyEvents(GetEventsRequest request)
 {
     var response = new GetEventsResponse();
     var calendarEvents = _calendarEventRepository.FindBy(d => d.Start >= request.Start && d.End <= request.End).ToList();
     var calendarView = new CalendarView();
     foreach (var myEvent in calendarEvents)
     {
         var editableEvent =
             myEvent.EventPermissions.FirstOrDefault(
                 p => (EnumPermission) p.PermissionType == EnumPermission.Modify && p.UserId == request.UserId);
         if (editableEvent != null)
         {
             calendarView.Events.Add(editableEvent.CalendarEvent.ConvertToEventView(false));
             continue;
         }
         var readonlyEvent =
             myEvent.EventPermissions.FirstOrDefault(
                 p => (EnumPermission) p.PermissionType == EnumPermission.ReadOnly && p.UserId == request.UserId);
         if (readonlyEvent != null)
         {
             calendarView.Events.Add(readonlyEvent.CalendarEvent.ConvertToEventView(true));
             continue;
         }
         if(myEvent.IsPublic)
         {
             calendarView.Events.Add(myEvent.ConvertToEventView(true));
         }
     }
     response.Calendar = calendarView;
     response.Success = true;
     return response;
 }
示例#2
0
 public GetEventsResponse GetPublicEvents(GetEventsRequest request)
 {
     var response = new GetEventsResponse();
     var calendarEvents =
         _calendarEventRepository.FindBy(
             d => d.Start >= request.Start && d.End <= request.End && d.IsPublic);
     var calendarView = new CalendarView();
     foreach(var publicEvent in calendarEvents)
     {
         calendarView.Events.Add(publicEvent.ConvertToEventView(true));
     }
     response.Calendar = calendarView;
     response.Success = true;
     return response;
 }