public OperationReturnModel <List <ListModel> > CopyList(ListCopyShareModel copyListModel) { OperationReturnModel <List <ListModel> > ret = new OperationReturnModel <List <ListModel> >(); try { var list = _listService.CopyList(this.AuthenticatedUser, this.SelectedUserContext, copyListModel); foreach (ListModel l in list) { _cacheListLogic.RemoveSpecificCachedList(l); } _cacheListLogic.ClearCustomersListCaches(this.AuthenticatedUser, this.SelectedUserContext, _listService.ReadUserList(this.AuthenticatedUser, this.SelectedUserContext, true)); ret.SuccessResponse = list; ret.IsSuccess = true; } catch (Exception ex) { ret.IsSuccess = false; ret.ErrorMessage = ex.Message; _elRepo.WriteErrorLog("CopyList", ex); } return(ret); }
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); }