Example #1
0
        public TraderForClients MarkTrader(int clientId, int traderId, bool?bookMark)
        {
            ClientService.CheckCredentials(clientId);
            if (bookMark == null)
            {
                throw new AppException("Missing parameters", 400);
            }
            (CommercialLink cl, _, Trader trader) = FindOrCreateCl(clientId, traderId);
            cl.Status = cl.Status.SetBit(CommercialLink.BOOKMARK, (bool)bookMark);
            ClService.QuickUpdate(cl.Id, cl);
            PrivateTrader    dto      = TraderService.EntityToDTO(cl.Trader);
            TraderForClients extended = dto.CastAs <TraderForClients>();

            extended.CommercialRelation = ClService.GetClStatus(cl);
            return(extended);
        }
Example #2
0
        public IEnumerable <TraderForClients> TradersForClient(int id, string filter)
        {
            ClientService.CheckCredentials(id);
            Client client = ClientService.FindEntity(id);

            ClientService.CollectCl(client);
            var ret = new List <TraderForClients>();
            Func <TraderForClients, bool> test = filter.ToTest <TraderForClients>();

            foreach (CommercialLink cl in client.CommercialLink)
            {
                PrivateTrader    privateTrader   = TraderService.EntityToDTO(cl.Trader);
                TraderForClients traderForClient = privateTrader.CastAs <TraderForClients>();
                traderForClient.CommercialRelation = ClService.GetClStatus(cl);
                if (test(traderForClient))
                {
                    ret.Add(traderForClient);
                }
            }
            return(ret);
        }