public bool Contains(TraderEntityDB entityToAdd) { return(this.dbContext.Traders.Any(t => t.Name == entityToAdd.Name && t.Surname == entityToAdd.Surname && t.PhoneNumber == entityToAdd.PhoneNumber)); }
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); }
public void Add(TraderEntityDB entity) { this.dbContext.Traders.Add(entity); }