Ejemplo n.º 1
0
        public void Test_UserCreate_ValueToModel()
        {
            var value = new UserCreate
            {
                CountryId = 1,
                TimeZoneId = 2,
                Name = "test",
                EmailAddress = "*****@*****.**",
                Password = "******",
                Dst = UserPreferenceDaylightSavingTime.On,
                StartOfWeek = UserPreferenceStartOfWeek.Monday,
                TimeFormat = UserPreferenceTimeFormat.Extended
            };

            var user = new User();

            value.ValueToModel(user);

            Assert.AreEqual("test", user.Name, "Name");
            Assert.AreEqual("*****@*****.**", user.EmailAddress, "EmailAddress");
            Assert.AreEqual("testing", user.Password, "Password");
            Assert.AreEqual(UserPreferenceDaylightSavingTime.On, value.Preference.Dst, "Dst");
            Assert.AreEqual(UserPreferenceStartOfWeek.Monday, value.Preference.StartOfWeek, "StartOfWeek");
            Assert.AreEqual(UserPreferenceTimeFormat.Extended, value.Preference.TimeFormat, "TimeFormat");
        }
Ejemplo n.º 2
0
        public ActionResult Create(UserCreate value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            value.Validate();

            if (value.IsValid)
            {
                var user = this.UserService.Create();

                value.ValueToModel(user);

                this.UserService.Insert(user, value.Preference);

                return Status(Messages.UserAccountCreated);
            }

            value.CopyToModel(ModelState);

            return base.View(Views.Create, value);
        }