Example #1
0
        public IActionResult CreateList([FromBody] AddListDto listDto)
        {
            var userId    = User.GetUserId();
            var addedList = _listService.CreateList(listDto, userId);

            if (addedList == null)
            {
                return(BadRequest());
            }
            return(CreatedAtRoute("GetList", new
            {
                id = addedList.Id
            }, addedList));
        }
Example #2
0
        public IActionResult CreateNewList([FromBody] TodoListDto value)
        {
            // Create new list
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                _service.CreateList(value);
            }
            catch
            {
                // TODO return the correct respnce.
                return(null);
            }

            return(CreatedAtAction("Get", new { id = value.Id }, value));
        }
 public APIResponse CreateList(ListDTO lists)
 {
     try
     {
         return(new APIResponse
         {
             returnCode = 0,
             returnMessage = "Success",
             returnObject = _listtService.CreateList(lists)
         });
     }
     catch (Exception ex)
     {
         return(new APIResponse
         {
             returnCode = -1,
             returnMessage = ex.Message.ToString()
         });
     }
 }
Example #4
0
        public async Task <OperationReturnModel <ListImportModel> > List()
        {
            OperationReturnModel <ListImportModel> ret = new OperationReturnModel <ListImportModel>();

            try
            {
                var importReturn = new ListImportModel();

                ListImportFileModel fileModel = await ImportHelper.GetFileFromContent(Request.Content);

                ListModel newList     = _importService.BuildList(this.AuthenticatedUser, this.SelectedUserContext, fileModel);
                ListModel createdList = _listService.CreateList(AuthenticatedUser, SelectedUserContext, ListType.Custom, newList);

                importReturn.List = _listService.ReadList(this.AuthenticatedUser, this.SelectedUserContext, createdList.Type, createdList.ListId, true);

                _cacheListLogic.RemoveSpecificCachedList(new ListModel()
                {
                    BranchId       = SelectedUserContext.BranchId,
                    CustomerNumber = SelectedUserContext.CustomerId,
                    ListId         = createdList.ListId,
                    Type           = createdList.Type
                });

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

                importReturn.List = _listService.ReadList(this.AuthenticatedUser, this.SelectedUserContext, createdList.Type, createdList.ListId, true);

                importReturn.Success        = true;
                importReturn.WarningMessage = _importService.Warnings;
                importReturn.ErrorMessage   = _importService.Errors;
                ret.SuccessResponse         = importReturn;
                ret.IsSuccess = true;
            }
            catch (Exception ex)
            {
                ret.IsSuccess    = false;
                ret.ErrorMessage = ex.Message;
                _log.WriteErrorLog("Import List", ex);
            }
            return(ret);
        }
Example #5
0
        public OperationReturnModel <ListModel> List(ListModel list, [FromUri] ListType type = ListType.Custom, [FromUri] bool isCustomInventory = false)
        {
            OperationReturnModel <ListModel> ret = new OperationReturnModel <ListModel>();

            try
            {
                List <ListItemModel> items = list.Items;
                if (isCustomInventory)
                {
                    list.Items = new List <ListItemModel>();
                }
                ret.SuccessResponse = _listService.CreateList(this.AuthenticatedUser, this.SelectedUserContext, type, list);

                _cacheListLogic.RemoveSpecificCachedList(new ListModel()
                {
                    BranchId       = SelectedUserContext.BranchId,
                    CustomerNumber = SelectedUserContext.CustomerId,
                    Type           = ret.SuccessResponse.Type,
                    ListId         = ret.SuccessResponse.ListId
                });

                _cacheListLogic.RemoveTypeOfListsCache(SelectedUserContext, type);

                _cacheListLogic.ClearCustomersListCaches(this.AuthenticatedUser, this.SelectedUserContext, _listService.ReadUserList(this.AuthenticatedUser, this.SelectedUserContext, true));
                if (isCustomInventory)
                {
                    long        listid             = (ret.SuccessResponse != null) ? ret.SuccessResponse.ListId : list.ListId;
                    List <long> customInventoryIds = items.Select(i => i.CustomInventoryItemId).ToList();
                    AddCustomInventoryItems(list.Type, listid, customInventoryIds);
                }
                ret.IsSuccess = true;
            }
            catch (Exception ex)
            {
                ret.IsSuccess    = false;
                ret.ErrorMessage = ex.Message;
                _elRepo.WriteErrorLog("List", ex);
            }
            return(ret);
        }
 public bool CreateList(ListDTO lists)
 {
     lists.CreatedDate = DateTime.UtcNow;
     return(_listtService.CreateList(lists));
 }
Example #7
0
        public async Task <IActionResult> Post(List list)
        {
            await _listService.CreateList(list);

            return(Ok(list));
        }
Example #8
0
 public IActionResult Post([FromBody] List list)
 {
     _listService.CreateList(list.BoardId, list);
     return(Created("api/Lists", list));
 }
 public async Task Handle(AddListCommand message, IMessageHandlerContext context)
 {
     await _listService.CreateList(message.Model);
 }