예제 #1
0
 public IActionResult Create(List list)
 {
     try
     {
         _listService.Create(list);
         return(Ok(new { Message = "Successful" }));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
        public SPList Create(SPListCreateOptions options)
        {
            try
            {
                Events.OnBeforeCreate(new SPList {
                    SPWebUrl = options.SPWebUrl, Title = options.Title, Description = options.Description
                });
            }
            catch (Exception ex)
            {
                string message = string.Format("An exception of type {0} occurred in the PublicApi.Lists.Events.OnBeforeCreate() method GroupId: {1}. The exception message is: {2}", ex.GetType(), options.GroupId, ex.Message);
                SPLog.UnKnownError(ex, message);
            }

            var template = SP.ListTemplateType.GenericList;

            if (!string.IsNullOrEmpty(options.Template))
            {
                Enum.TryParse(options.Template, out template);
            }

            var list = listService.Create((int)template, options);

            ExpireTags(options.GroupId);

            var group = TEApi.Groups.Get(new Extensibility.Api.Version1.GroupsGetOptions {
                Id = list.GroupId
            });

            SecurityService.RecalculatePermissions(list.Id, ListApplicationType.Id, group.ApplicationId);

            if (!list.HasErrors())
            {
                cacheService.Put(CacheKey(list.Id), list, CacheScope.Context | CacheScope.Process, new[] { Tag(list.GroupId) }, CacheTimeOut);
                try
                {
                    Events.OnAfterCreate(list);
                }
                catch (Exception ex)
                {
                    string message = string.Format("An exception of type {0} occurred in the PublicApi.Lists.Events.OnAfterCreate() method GroupId: {1} ListId: {2} SPWebUrl: {3}. The exception message is: {4}", ex.GetType(), options.GroupId, list.Id, list.SPWebUrl, ex.Message);
                    SPLog.UnKnownError(ex, message);
                }
            }

            return(list);
        }
예제 #3
0
        public IActionResult CreateList([FromBody] CreateListDto createListDto)
        {
            var list = _mapper.Map <List>(createListDto);

            try
            {
                var createdList = _listService.Create(list);

                var res = new ObjectResult(new { listId = createdList.Id });
                res.StatusCode = StatusCodes.Status201Created;

                return(res);
            }
            catch (Exception ex)
            {
                return(BadRequest(new { message = ex.Message }));
            }
        }
        public Library Create(LibraryCreateOptions options)
        {
            try
            {
                Events.OnBeforeCreate(new Library {
                    SPWebUrl = options.SPWebUrl, Name = options.Title, Description = options.Description
                });
            }
            catch (Exception ex)
            {
                string message = string.Format("An exception of type {0} occurred in the PublicApi.Libraries.Events.OnBeforeCreate() method GroupId: {1}. The exception message is: {2}", ex.GetType(), options.GroupId, ex.Message);
                SPLog.UnKnownError(ex, message);
            }

            var library = new Library(listService.Create((int)SP.ListTemplateType.DocumentLibrary, options));

            ExpireTags(options.GroupId);

            var group = TEApi.Groups.Get(new Extensibility.Api.Version1.GroupsGetOptions {
                Id = library.GroupId
            });

            SecurityService.RecalculatePermissions(library.Id, LibraryApplicationType.Id, group.ApplicationId);

            cacheService.Put(CacheKey(library.Id), library, CacheScope.Context | CacheScope.Process, new[] { Tag(library.GroupId) }, CacheTimeOut);
            try
            {
                Events.OnAfterCreate(library);
            }
            catch (Exception ex)
            {
                string message = string.Format("An exception of type {0} occurred in the PublicApi.Libraries.Events.OnAfterCreate() method GroupId: {1} LibraryId: {2} SPWebUrl: {3}. The exception message is: {4}", ex.GetType(), options.GroupId, library.Id, library.SPWebUrl, ex.Message);
                SPLog.UnKnownError(ex, message);
            }

            return(library);
        }
예제 #5
0
        public async Task <ActionResult <ListResponse> > PostList(ListRequest listRequest)
        {
            var listResponse = await _ListService.Create(listRequest);

            return(CreatedAtAction(nameof(GetList), new { id = listResponse.Value.Id }, listResponse.Value));
        }
예제 #6
0
        public ActionResult <ToDoList> Create(ToDoList list)
        {
            listService.Create(list);

            return(CreatedAtRoute("GetList", new { id = list.Id }, list));
        }