Ejemplo n.º 1
0
        public OperationReturnModel <bool> AddItem(ListType type, long listId, ListItemModel newItem)
        {
            OperationReturnModel <bool> ret = new OperationReturnModel <bool>();

            try {
                _listService.AddItem(this.AuthenticatedUser, this.SelectedUserContext, type,
                                     listId, newItem);

                var list = new ListModel()
                {
                    BranchId       = SelectedUserContext.BranchId,
                    CustomerNumber = SelectedUserContext.CustomerId,
                    Type           = type,
                    ListId         = listId
                };

                _cacheListLogic.RemoveSpecificCachedList(list);

                _cacheListLogic.ClearCustomersListCaches(this.AuthenticatedUser, this.SelectedUserContext, _listService.ReadUserList(this.AuthenticatedUser, this.SelectedUserContext, true));

                ret.SuccessResponse = true;
                ret.IsSuccess       = true;
            } catch (Exception ex) {
                ret.SuccessResponse = false;
                ret.IsSuccess       = false;
                ret.ErrorMessage    = ex.Message;

                _elRepo.WriteErrorLog("AddItem", ex);
            }

            return(ret);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Executed when button "Add" is pressed
        /// </summary>
        void ExecuteAddItemToList()
        {
            // Add item to the list
            _listService.AddItem(Item);

            // Get updated list from service
            ItemsList = _listService.GetList();

            // Reset the textbox text
            Item = null;
        }
Ejemplo n.º 3
0
        public ActionResult <ListDto> AddItem(int listId, string item)
        {
            var serviceResult = _listService.AddItem(item, listId);

            if (serviceResult.ResponseCode != ResponseCode.Success)
            {
                return(BadRequest(serviceResult.Error));
            }

            var list = serviceResult.Result;

            return(Ok(new ListDto
            {
                Name = list.Name,
                Id = list.Id,
                Items = list.Items
            }));
        }