Exemplo n.º 1
0
        public void UpdateById(int id, TEntityType entity, LibraryUpdateOptions options = LibraryUpdateOptions.None)
        {
            var item = List.GetItemById(id);

            mapper.MapEntityToItem(entity, item);
            item.Update();

            if ((options & LibraryUpdateOptions.DoNotExecuteQuery) != LibraryUpdateOptions.DoNotExecuteQuery)
            {
                List.Context.ExecuteQuery();
            }
        }
Exemplo n.º 2
0
        public AdditionalInfo Update(Guid libraryId,
                                     [Documentation(Name = "Title", Type = typeof(string)),
                                      Documentation(Name = "Description", Type = typeof(string)),
                                      Documentation(Name = "DefaultViewId", Type = typeof(Guid))]
                                     IDictionary options)
        {
            var result = new AdditionalInfo();

            if (options == null)
            {
                return(result);
            }

            var updateOptions = new LibraryUpdateOptions(libraryId);

            if (options["Title"] != null)
            {
                updateOptions.Title = options["Title"].ToString();
            }
            if (options["Description"] != null)
            {
                updateOptions.Description = options["Description"].ToString();
            }
            if (options["DefaultViewId"] is Guid)
            {
                updateOptions.DefaultViewId = (Guid)options["DefaultViewId"];
            }
            if (updateOptions.Title != null ||
                updateOptions.Description != null ||
                updateOptions.DefaultViewId != Guid.Empty)
            {
                try
                {
                    PublicApi.Libraries.Update(updateOptions);
                }
                catch (SPInternalException ex)
                {
                    result.Errors.Add(new Error(ex.GetType().ToString(), plugin.Translate(SharePointLibraryExtension.Translations.CannotBeUpdated)));
                }
                catch (Exception ex)
                {
                    string message = string.Format("An exception of type {0} occurred in the WidgetApi.V2.SharePointLibrary.Update() method while updating library with Id: {1}. The exception message is: {2}", ex.GetType(), libraryId, ex.Message);
                    SPLog.UnKnownError(ex, message);
                    result.Errors.Add(new Error(ex.GetType().ToString(), plugin.Translate(SharePointLibraryExtension.Translations.UnknownError)));
                }
            }
            return(result);
        }
Exemplo n.º 3
0
        public void Update(TEntityType entity, LibraryUpdateOptions options = LibraryUpdateOptions.None)
        {
            var id = mapper.GetId(entity);

            UpdateById(id, entity, options);
        }