Пример #1
0
        private (CommercialLink, Client, Trader) FindOrCreateCl(int clientId, int traderId)
        {
            Client         client = ClientService.FindEntity(clientId);
            Trader         trader = TraderService.FindEntity(traderId);
            CommercialLink cl     = ClService.FindWithBoth(clientId, traderId);

            if (cl == null)
            {
                cl = new CommercialLink()
                {
                    ClientId = clientId,
                    TraderId = traderId,
                    Status   = CommercialLink.DEFAULT_STATUS
                };
                ClService.QuickSave(cl);
            }
            return(cl, client, trader);
        }
Пример #2
0
        public IEnumerable <ClientForTraders> ClientsForTrader(int id, string filter)
        {
            TraderService.CheckCredentials(id);
            Trader trader = TraderService.FindEntity(id);

            TraderService.CollectCl(trader);
            var ret = new List <ClientForTraders>();
            Func <ClientForTraders, bool> test = filter.ToTest <ClientForTraders>();

            foreach (CommercialLink cl in trader.CommercialLink)
            {
                PrivateClient    privateClient   = ClientService.EntityToDTO(cl.Client);
                ClientForTraders clientForTrader = privateClient.CastAs <ClientForTraders>();
                clientForTrader.CommercialRelation = ClService.GetClStatus(cl);
                if (test(clientForTrader))
                {
                    ret.Add(clientForTrader);
                }
            }
            return(ret);
        }