示例#1
0
 public void InsertCustomer(Customer customer)
 {
     if (customer.CustomerID == 0)
     {
         CustomerDAL.InsertCustomer(customer);
     }
     else
     {
         CustomerDAL.UpdateCustomer(customer);
     }
 }
示例#2
0
        //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);
            }
        }