public Response <Customer> AddEditCustomer(Customer customer, bool edit = false) { var res = new Response <Customer>(); if (edit) { var c = _repository.GetCustomer_Id(customer.Id); if (c == null) { res.Customer = c; res.Exists = false; } else { // ideally this would go into a mapper class c.FirstName = customer.FirstName; c.LastName = customer.LastName; c.DateOfBirth = customer.DateOfBirth; res.Customer = _repository.AddEditCustomer(c); res.Exists = true; } } else { var exists = _repository.GetCustomer_FirstLastName(customer); var c = exists ? null : _repository.AddEditCustomer(customer); res.Customer = c; res.Exists = exists; } return(res); }