public (PurchaseDTO, int) SavePurchase(int clientId, int traderId, decimal amount) { TraderService.CheckCredentials(traderId); (CommercialLink cl, _, _) = FindOrCreateCl(clientId, traderId); Purchase purchase = PurchaseService.Save(new Purchase() { CommercialLinkId = cl.Id, PayingTime = null, Amount = amount }); return(PurchaseService.EntityToDTO(purchase), purchase.Id); }
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); }