예제 #1
0
        public static RequestBuilder UpdateCalendarGroup(CalendarGroup calendarGroup, string calendar_group_id)
        {
            Request Request = new Request("/calendargroups/" + calendar_group_id, Method2.PATCH);

            Request = CalendarGroupParameters(Request);
            Request.AddBody(calendarGroup);
            return(new RequestBuilder(Request));
        }
예제 #2
0
        public static RequestBuilder CreateCalendarGroup(CalendarGroup calendarGroup)
        {
            Request Request = new Request("/calendargroups", Method2.GET);

            Request = CalendarGroupParameters(Request);
            Request.AddBody(calendarGroup);
            return(new RequestBuilder(Request));
        }
예제 #3
0
        public static CalendarGroup CreateFromId(string ID)
        {
            CalendarGroup newCalendarGroup = new CalendarGroup()
            {
                Id = ID
            };

            return(newCalendarGroup);
        }
 public ActionResult Create(CalendarGroup cgroup)
 {
     if (ModelState.IsValid)
     {
         db.CalendarGroups.Add(cgroup);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(cgroup));
 }
예제 #5
0
        public async Task <List <CalendarGroup> > GetAllCalendarGroupsAsync()
        {
            // Get all calendar groups.
            // The property of the item to get is very limited.

            Uri    URL;
            string idAttributeName;
            string nameAttributeName;

            if (Util.UseMicrosoftGraphInMailboxViewer)
            {
                URL               = new Uri("https://graph.microsoft.com/v1.0/me/calendargroups?$top=100&$select=Id,Name");
                idAttributeName   = "id";
                nameAttributeName = "name";
            }
            else
            {
                URL               = new Uri("https://outlook.office.com/api/v2.0/me/calendargroups?$top=100&$select=Id,Name");
                idAttributeName   = "Id";
                nameAttributeName = "Name";
            }


            string stringResponse = "";

            try
            {
                stringResponse = await SendGetRequestAsync(URL);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            // Convert JSON response.

            var jsonResponse   = (JObject)JsonConvert.DeserializeObject(stringResponse);
            var calendarGroups = (JArray)jsonResponse.GetValue("value");

            List <CalendarGroup> result = new List <CalendarGroup>();

            foreach (var group in calendarGroups)
            {
                string id   = group.Value <string>(idAttributeName);
                string name = group.Value <string>(nameAttributeName);

                var newCalendarGroup = CalendarGroup.CreateFromId(id);
                newCalendarGroup.Name = name;

                result.Add(newCalendarGroup);
            }

            return(result);
        }
        public ActionResult Edit(CalendarGroup cgroup)
        {
            if (ModelState.IsValid)
            {
                db.Entry(cgroup).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(cgroup));
        }
예제 #7
0
        public async Task CreateGroupCalendar()
        {
            var calendarGroup = new CalendarGroup
            {
                Name      = "DEMO-GROUP-CALENDAR",
                ClassId   = Guid.Parse("c8ea0ed1-3834-4d80-ba48-9552c4d2e689"),
                ChangeKey = "changeKey-value"
            };

            await _client.Me.CalendarGroups.Request().AddAsync(calendarGroup);
        }
        /// <summary>
        /// Create new navigation property to calendarGroups for users
        /// <param name="body"></param>
        /// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
        /// </summary>
        public RequestInformation CreatePostRequestInformation(CalendarGroup body, Action <CalendarGroupsRequestBuilderPostRequestConfiguration> requestConfiguration = default)
        {
            _ = body ?? throw new ArgumentNullException(nameof(body));
            var requestInfo = new RequestInformation {
                HttpMethod     = Method.POST,
                UrlTemplate    = UrlTemplate,
                PathParameters = PathParameters,
            };

            requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body);
            if (requestConfiguration != null)
            {
                var requestConfig = new CalendarGroupsRequestBuilderPostRequestConfiguration();
                requestConfiguration.Invoke(requestConfig);
                requestInfo.AddRequestOptions(requestConfig.Options);
                requestInfo.AddHeaders(requestConfig.Headers);
            }
            return(requestInfo);
        }
예제 #9
0
        public string GetCalendarFolder()
        {
            CalendarGroup[] array = new CalendarGroup[]
            {
                new CalendarGroup()
            };
            array[0].GroupId   = Guid.Empty.ToString();
            array[0].GroupType = CalendarGroupType.MyCalendars;
            array[0].GroupName = string.Empty;
            array[0].ItemId    = new Microsoft.Exchange.Services.Core.Types.ItemId(array[0].GroupId, array[0].GroupId);
            array[0].Calendars = new CalendarEntry[1];
            LocalCalendarEntry localCalendarEntry = new LocalCalendarEntry();

            localCalendarEntry.CalendarColor     = CalendarColor.Auto;
            localCalendarEntry.IsDefaultCalendar = true;
            array[0].Calendars[0] = localCalendarEntry;
            CalendarFolderType calendarFolderType = new CalendarFolderType();

            calendarFolderType.FolderId                                  = IdConverter.GetFolderIdFromStoreId(AnonymousUserContext.Current.PublishedCalendarId, new MailboxId(AnonymousUserContext.Current.ExchangePrincipal.MailboxInfo.MailboxGuid));
            localCalendarEntry.ItemId                                    = new Microsoft.Exchange.Services.Core.Types.ItemId("calendarEntryFor" + calendarFolderType.FolderId.Id, "calendarEntryChangeKeyFor" + calendarFolderType.FolderId.ChangeKey);
            calendarFolderType.DisplayName                               = AntiXssEncoder.HtmlEncode(AnonymousUserContext.Current.PublishedCalendarName, false);
            calendarFolderType.ChildFolderCount                          = new int?(0);
            calendarFolderType.ChildFolderCountSpecified                 = true;
            calendarFolderType.ExtendedProperty                          = null;
            calendarFolderType.FolderClass                               = "IPF.Appointment";
            calendarFolderType.EffectiveRights                           = new EffectiveRightsType();
            calendarFolderType.EffectiveRights.CreateAssociated          = false;
            calendarFolderType.EffectiveRights.CreateContents            = false;
            calendarFolderType.EffectiveRights.CreateHierarchy           = false;
            calendarFolderType.EffectiveRights.Delete                    = false;
            calendarFolderType.EffectiveRights.Modify                    = false;
            calendarFolderType.EffectiveRights.Read                      = true;
            calendarFolderType.EffectiveRights.ViewPrivateItemsSpecified = false;
            localCalendarEntry.CalendarFolderId                          = calendarFolderType.FolderId;
            GetCalendarFoldersResponse instance = new GetCalendarFoldersResponse(array, new CalendarFolderType[]
            {
                calendarFolderType
            });

            return(SessionDataHandler.EmitPayload("calendarFolders", JsonConverter.ToJSON(instance)));
        }
예제 #10
0
        public async Task <CalendarGroup> GetCalendarGroupAsync(string CalendarGroupId)
        {
            // Get the specified calendar group.

            Uri URL = Util.UseMicrosoftGraphInMailboxViewer ? new Uri($"https://graph.microsoft.com/v1.0/me/calendargroups/{CalendarGroupId}") : new Uri($"https://outlook.office.com/api/v2.0/me/calendargroups/{CalendarGroupId}");

            string stringResponse = "";

            try
            {
                stringResponse = await SendGetRequestAsync(URL);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            var calendarGroup = new CalendarGroup(stringResponse);

            return(calendarGroup);
        }