public void AddClient(string clientName) { if (!ExistClient(clientName)) { using (BaseContext ctx = new BaseContext()) { Client client = new Client() { Name = clientName }; ctx.Clients.Add(client); ctx.SaveChanges(); } } }
public Client GetClient(string nameClient) { using (BaseContext ctx = new BaseContext()) { if (ExistClient(nameClient)) { var temper = ctx.Clients.Where(x => x.Name == nameClient).FirstOrDefault(); return temper; } else { Client client = new Client() { Id = 00, Name = "Клиент не найден" }; return client; } } }