示例#1
0
        public OperationReturnModel <bool> ClearCustomersLists()
        {
            OperationReturnModel <bool> ret = new OperationReturnModel <bool>();

            try {
                if (AuthenticatedUser.RoleName.Equals("beksysadmin", StringComparison.CurrentCultureIgnoreCase))
                {
                    _cacheListLogic.ClearCustomersListCaches(AuthenticatedUser, SelectedUserContext, _listService.ReadUserList(AuthenticatedUser, SelectedUserContext, true));
                    ret = new OperationReturnModel <bool>()
                    {
                        SuccessResponse = true, IsSuccess = true
                    };
                }
                else
                {
                    ret.ErrorMessage = "Must be a beksysadmin user";
                    ret.IsSuccess    = false;
                }
            }
            catch (Exception ex)
            {
                ret.IsSuccess    = false;
                ret.ErrorMessage = ex.Message;
                _elRepo.WriteErrorLog("ClearCustomersLists", ex);
            }
            return(ret);
        }
示例#2
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);
        }
示例#3
0
            public void CallWith2ListsInCollection_CallsCacheRepositoryRemoveItem10Times()
            {
                // arrange
                var             mockDependents = new MockDependents();
                ICacheListLogic testunit       = MakeTestsLogic(false, ref mockDependents);
                var             testContext    = new UserSelectedContext
                {
                    BranchId   = "FUT",
                    CustomerId = "234567"
                };
                var fakeUser  = new UserProfile();
                var testLists = new List <ListModel>
                {
                    new ListModel
                    {
                        BranchId       = "FUT",
                        CustomerNumber = "123456",
                        Type           = ListType.Contract,
                        ListId         = 5
                    },
                    new ListModel
                    {
                        BranchId       = "FUT",
                        CustomerNumber = "123456",
                        Type           = ListType.Favorite,
                        ListId         = 5
                    }
                };

                // act
                testunit.ClearCustomersListCaches(fakeUser, testContext.CustomerId, testContext.BranchId, testLists);

                // assert
                mockDependents.CacheRepository.Verify(m => m.RemoveItem(It.IsAny <string>(),
                                                                        It.IsAny <string>(),
                                                                        It.IsAny <string>(),
                                                                        It.IsAny <string>()), Times.Exactly(10), "not called");
            }
示例#4
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);
        }