public Contract.Entities.Client AddClient(Contract.Entities.Client client) { var created = Context.Add(new Client() { Id = client.Id, Name = client.Name, City = client.City, Address = client.Address, CountryId = client.CountryId, Postal = client.Postal }); Context.SaveChanges(); return(Mapper.Map <Contract.Entities.Client>(created.Entity)); }
public Contract.Entities.Client UpdateClient(Contract.Entities.Client client) { var updatedClient = Context.Clients.FirstOrDefault(e => e.Id == client.Id); if (updatedClient == null) { throw new ValidationException(); } updatedClient.Name = client.Name; updatedClient.Postal = client.Postal; updatedClient.Address = client.Address; updatedClient.City = client.City; updatedClient.CountryId = client.CountryId; Context.SaveChanges(); return(Mapper.Map <Contract.Entities.Client>(updatedClient)); }