Esempio n. 1
0
        public bool SaveData()
        {
            Bus.Customer customer = ModelFromView();

            if (this.HasChanged())
            {
                if (this.ValidateData(customer))
                {
                    try {
                        customer.Update();

                        CustomerSaveEventArgs args = new CustomerSaveEventArgs();
                        args.CustomerId  = this.CustomerId;
                        args.NewFullName = customer.Model.LastName + ", " + customer.Model.FirstName;
                        OnCustomerSave(this, args);

                        customer = null;

                        return(true);
                    } catch (Exception x) {
                        //KF: This is only very basic exception handling, a full solution would look for inner exceptions, particular types and much more
                        g.LogEvent("Save Error: " + x.Message, EventLogging.Events.EventLevel.Exception);
                    }
                }
                return(false);
            }
            else
            {
                //If nothing to do return true
                return(true);
            }
        }
Esempio n. 2
0
        public void UpdateCustomer()
        {
            GenesisModels.Customer modelCustomer = new GenesisModels.Customer();
            modelCustomer.Id        = Guid.Parse("88A96958-A302-4913-9ADC-1997B49C7571");
            modelCustomer.FirstName = "Kevin";
            modelCustomer.LastName  = "Finegan";

            Bus.Customer customer = new Bus.Customer(modelCustomer);

            customer.Update();

            customer = null;
        }