Example #1
0
        public OperationReturnModel <bool> ClearCustomersLabels()
        {
            OperationReturnModel <bool> ret = new OperationReturnModel <bool>();

            try
            {
                if (AuthenticatedUser.RoleName.Equals("beksysadmin", StringComparison.CurrentCultureIgnoreCase))
                {
                    _cacheListLogic.ClearCustomersLabelsCache(SelectedUserContext);
                    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);
        }
Example #2
0
            public void AnyCall_CallsCacheRepositoryRemoveTimes()
            {
                // arrange
                var             mockDependents = new MockDependents();
                ICacheListLogic testunit       = MakeTestsLogic(false, ref mockDependents);
                var             testContext    = new UserSelectedContext
                {
                    BranchId   = "FUT",
                    CustomerId = "234567"
                };

                // act
                testunit.ClearCustomersLabelsCache(testContext.CustomerId, testContext.BranchId);

                // assert
                mockDependents.CacheRepository.Verify(m => m.RemoveItem(It.IsAny <string>(),
                                                                        It.IsAny <string>(),
                                                                        It.IsAny <string>(),
                                                                        It.IsAny <string>()), Times.Once, "not called");
            }
Example #3
0
        public OperationReturnModel <string> ShareList(ListCopyShareModel copyListModel)
        {
            OperationReturnModel <string> ret = new OperationReturnModel <string>();

            try {
                var existingShares = _customListSharesRepo.GetCustomListSharesByHeaderId(copyListModel.ListId);

                foreach (var share in existingShares)
                {
                    _customListSharesRepo.DeleteCustomListShares(share.Id);

                    _cacheListLogic.ClearCustomersListCaches(AuthenticatedUser,
                                                             share.CustomerNumber,
                                                             share.BranchId,
                                                             _listService.ReadUserList(AuthenticatedUser,
                                                                                       new UserSelectedContext()
                    {
                        CustomerId = share.CustomerNumber,
                        BranchId   = share.BranchId
                    }, true));

                    _cacheListLogic.ClearCustomersLabelsCache(share.CustomerNumber, share.BranchId);
                }

                foreach (var customer in copyListModel.Customers)
                {
                    _customListSharesRepo.SaveCustomListShare(new CustomListShare()
                    {
                        Active         = true,
                        HeaderId       = copyListModel.ListId,
                        CustomerNumber = customer.CustomerNumber,
                        BranchId       = customer.CustomerBranch
                    });

                    _cacheListLogic.ClearCustomersListCaches(AuthenticatedUser,
                                                             new UserSelectedContext()
                    {
                        CustomerId = customer.CustomerNumber,
                        BranchId   = customer.CustomerBranch
                    },
                                                             _listService.ReadUserList(AuthenticatedUser,
                                                                                       new UserSelectedContext()
                    {
                        CustomerId = customer.CustomerNumber,
                        BranchId   = customer.CustomerBranch
                    }, true));

                    _cacheListLogic.ClearCustomersLabelsCache(new UserSelectedContext()
                    {
                        CustomerId = customer.CustomerNumber,
                        BranchId   = customer.CustomerBranch
                    });
                }

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

                _cacheListLogic.ClearCustomersLabelsCache(SelectedUserContext);

                ret.SuccessResponse = null;
                ret.IsSuccess       = true;
            } catch (Exception ex) {
                ret.IsSuccess    = false;
                ret.ErrorMessage = ex.Message;
                _elRepo.WriteErrorLog("ShareList", ex);
            }
            return(ret);
        }