public ActionResult UpdatePersonAsync()
        {
            var edited = new UserModel();

            if (TryUpdateModel(edited))
            {
                var current = Repository.Data.Get<Person>(edited.Id);
                current.CopyFrom(edited);
                Repository.Data.Save(current);
            }

            return GetPersonsAsync(new GridCommand { Page = 1, PageSize = 20 });
        }
        public static void CopyFrom(this Person source, UserModel copied)
        {
            source.Active = copied.Active;

            if (source.Profile == null)
                source.Profile = new PersonProfile();

            source.Profile.FirstName = copied.FirstName;
            source.Profile.LastName = copied.LastName;
            source.Profile.MiddleName = copied.MiddleName;
            source.Profile.PhoneHome = copied.PhoneHome;
            source.Profile.PhoneMobile = copied.PhoneMobile;
            source.Profile.Email = copied.Email;

            if (source.DeliveryAddress == null)
                source.DeliveryAddress = new Address();

            source.DeliveryAddress.Address1 = copied.Address1;
            source.DeliveryAddress.City = copied.City;
        }
        public ActionResult InsertPersonAsync()
        {
            var inserting = new UserModel();

            if (TryUpdateModel(inserting))
            {
                Person person = new Person();
                person.Profile = new PersonProfile();
                person.DeliveryAddress = new Address();
                person.CopyFrom(inserting);

                person.LastLoginDate = DateTime.Now;
                person.LoginName = String.Format("{0} {1}", inserting.FirstName, inserting.LastName );
                person.SetPassword(inserting.Password);
                person.Role =UserRole.Customer;
                Repository.Data.Save(person);
            }

            return GetPersonsAsync(new GridCommand { Page = 1, PageSize = 20 });
        }