public void InsertCustomer(Customer customer) { if (customer.CustomerID == 0) { CustomerDAL.InsertCustomer(customer); } else { CustomerDAL.UpdateCustomer(customer); } }
//spara /uppdatera public void InsertCustomer(Customer customer) { //validering ICollection<ValidationResult> validationResult; if (!customer.Validate(out validationResult)) { var ex = new ValidationException("Kunden klarade inte valideringen"); ex.Data.Add("ValidationResult", validationResult); throw ex; } //spara kund if (customer.CustomerID == 0) { CustomerDAL.InsertCustomer(customer); } //uppdatera kund else { CustomerDAL.UpdateCustomer(customer); } }