public bool Contains(TraderEntityDB entityToAdd)
 {
     return(this.dbContext.Traders.Any(t =>
                                       t.Name == entityToAdd.Name &&
                                       t.Surname == entityToAdd.Surname &&
                                       t.PhoneNumber == entityToAdd.PhoneNumber));
 }
Esempio n. 2
0
        public int RegisterNewTrader(TraderInfo trader)
        {
            var entityToAdd = new TraderEntityDB()
            {
                CreatedAt   = DateTime.Now,
                Name        = trader.Name,
                Surname     = trader.Surname,
                PhoneNumber = trader.PhoneNumber,
                Balance     = trader.Balance
            };

            if (traderTableRepository.Contains(entityToAdd))
            {
                throw new ArgumentException($"This trader {entityToAdd.Name} {entityToAdd.Surname} has been registered.");
            }
            traderTableRepository.Add(entityToAdd);

            traderTableRepository.SaveChanges();

            return(entityToAdd.Id);
        }
Esempio n. 3
0
 public void Add(TraderEntityDB entity)
 {
     this.dbContext.Traders.Add(entity);
 }