Example #1
0
        private ListModel GetCompletedModel(CustomListHeader header, UserSelectedContext catalogInfo, bool headerOnly)
        {
            List <CustomListDetail> items  = null;
            List <CustomListShare>  shares = null;

            if (!headerOnly)
            {
                items  = _detailsRepo.GetCustomListDetails(header.Id);
                shares = _sharesRepo.GetCustomListSharesByHeaderId(header.Id);
            }

            return(header.ToListModel(catalogInfo, shares, items));
        }
Example #2
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);
        }