public void Insert(Client client) { var result = Clients.Where(p => p.sEmail.Equals(client.sEmail)); if (result.Count() > 0) { throw new InvalidOperationException("Cliente já cadastrado com esse email."); } if (client.dtBirth > DateTime.Today) { throw new InvalidOperationException("Data de nascimento não pode ser maior que atual."); } dbContext.Client.Add(client); dbContext.SaveChanges(); }
public void LimparCenario() { var clientToRemove = from p in clientContext.Client select p; foreach (var client in clientToRemove) { clientContext.Client.Remove(client); } clientContext.SaveChanges(); }