コード例 #1
0
        public void CreateListItem(ListItemModel listItemModel)
        {
            _log.Debug("userId={0}, {1}", userId, listItemModel);
            var newListItemModel = new ListItemModel(
                _listItemService.Create(listItemModel.Description, listItemModel.Quantity, listItemModel.ShoppingListId)
                );

            Clients.Group(listItemModel.ShoppingListId.ToString()).listItemCreated(newListItemModel);
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("Id,Quantity,ProductId,ShoppingListId")] ListItem listItem)
        {
            if (ModelState.IsValid)
            {
                await _listItemService.Create(listItem);

                return(RedirectToAction("Details", "ShoppingLists", new { id = listItem.ShoppingListId }));
            }

            //DORADI
            ViewData["ProductId"] = new SelectList(_productService.getAll(), "Id", "Name", listItem.ProductId);

            return(RedirectToAction("Index", "ShoppingLists"));
        }
コード例 #3
0
        public Document Create(Guid libraryId, DocumentCreateOptions options)
        {
            try
            {
                Events.OnBeforeCreate(new Document {
                    Url = options.Url, Name = options.FileName
                });
            }
            catch (Exception ex)
            {
                string message = string.Format("An exception of type {0} occurred in the PublicApi.Documents.Events.OnBeforeCreate() method for LibraryId: {1}. The exception message is: {2}", ex.GetType(), libraryId, ex.Message);
                SPLog.UnKnownError(ex, message);
            }

            var document   = new Document();
            var splistItem = listItemService.Create(libraryId, options);

            if (splistItem != null)
            {
                document = new Document(splistItem);
                ExpireTags(libraryId);
            }

            if (!document.HasErrors())
            {
                cacheService.Put(GetCacheId(document.ContentId), document, CacheScope.Context | CacheScope.Process, new[] { Tag(document.Library.Id) }, CacheTimeOut);
                try
                {
                    Events.OnAfterCreate(document);
                }
                catch (Exception ex)
                {
                    string message = string.Format("An exception of type {0} occurred in the PublicApi.Documents.Events.OnAfterCreate() method for LibraryId: {1}. The exception message is: {2}", ex.GetType(), libraryId, ex.Message);
                    SPLog.UnKnownError(ex, message);
                }
            }

            return(document);
        }
コード例 #4
0
        public SPListItem Create(Guid listId, SPListItemCreateOptions options)
        {
            try
            {
                Events.OnBeforeCreate(new SPListItem {
                    Url = options.Url, DisplayName = options.Name
                });
            }
            catch (Exception ex)
            {
                var message = string.Format("An exception of type {0} occurred in the PublicApi.ListItems.Events.OnBeforeCreate() method for ListId: {1}. The exception message is: {2}", ex.GetType(), listId, ex.Message);
                SPLog.UnKnownError(ex, message);
            }

            var listItem = listItemService.Create(listId, options);

            ExpireTags(listId);

            var newItem = Get(listId, new SPListItemGetOptions(listItem.ContentId));

            if (newItem == null)
            {
                return(null);
            }

            try
            {
                Events.OnAfterCreate(newItem);
            }
            catch (Exception ex)
            {
                var message = string.Format("An exception of type {0} occurred in the PublicApi.ListItems.Events.OnAfterCreate() method for ListId: {1}. The exception message is: {2}", ex.GetType(), listId, ex.Message);
                SPLog.UnKnownError(ex, message);
            }

            return(newItem);
        }