예제 #1
0
            public void CallWithGoodType_CallsCacheRepositoryRemoveItemTwice()
            {
                // arrange
                var             mockDependents = new MockDependents();
                ICacheListLogic testunit       = MakeTestsLogic(false, ref mockDependents);
                var             testContext    = new UserSelectedContext
                {
                    BranchId   = "FUT",
                    CustomerId = "234567"
                };
                var testListType = ListType.Custom;

                // act
                testunit.RemoveTypeOfListsCache(testContext, testListType);

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