상속: Entity
예제 #1
0
        public void CanCompareUsers()
        {
            var instance = new User {UserName = "******", Password = "******"};

            var instanceToCompareTo = new User {UserName = "******", Password = "******"};

            instance.ShouldEqual(instanceToCompareTo);
        }
        public ActionResult Create(User user)
        {
            if (ViewData.ModelState.IsValid) {
                ActionConfirmation saveOrUpdateConfirmation = userManagementService.SaveOrUpdate(user);

                if (saveOrUpdateConfirmation.WasSuccessful)
                {
                    TempData[ControllerEnums.GlobalViewDataProperty.PageMessage.ToString()] = saveOrUpdateConfirmation.Message;
                    return RedirectToAction("Index");
                }
            }

            UserFormViewModel viewModel = userManagementService.CreateFormViewModelFor(user);
            return View(viewModel);
        }
        public ActionConfirmation SaveOrUpdate(User user)
        {
            if (user.IsValid())
            {
                userRepository.SaveOrUpdate(user);

                ActionConfirmation saveOrUpdateConfirmation = ActionConfirmation.CreateSuccessConfirmation(
                    "The user was successfully saved.");
                saveOrUpdateConfirmation.Value = user;

                return saveOrUpdateConfirmation;
            }
            else
            {
                userRepository.DbContext.RollbackTransaction();

                return ActionConfirmation.CreateFailureConfirmation(
                    "The user could not be saved due to missing or invalid information.");
            }
        }
 public UserFormViewModel CreateFormViewModelFor(User user)
 {
     UserFormViewModel viewModel = CreateFormViewModel();
     viewModel.User = user;
     return viewModel;
 }
 private void TransferFormValuesTo(User userToUpdate, User userFromForm)
 {
     userToUpdate.UserName = userFromForm.UserName;
     userToUpdate.Password = userFromForm.Password;
 }
        public ActionConfirmation UpdateWith(User userFromForm)
        {
            User userToUpdate = userRepository.Get(userFromForm.Id);
            TransferFormValuesTo(userToUpdate, userFromForm);

            if (userToUpdate.IsValid())
            {
                ActionConfirmation updateConfirmation = ActionConfirmation.CreateSuccessConfirmation(
                    "The user was successfully updated.");
                updateConfirmation.Value = userToUpdate;

                return updateConfirmation;
            }
            else
            {
                userRepository.DbContext.RollbackTransaction();

                return ActionConfirmation.CreateFailureConfirmation(
                    "The user could not be saved due to missing or invalid information.");
            }
        }
        private List<User> CreateUsers()
        {
            var users = new List<User>();
            var user = new User {UserName = "******", Password = "******"};
            var user1 = new User { UserName = "******", Password = "******" };
            users.Add(user);
            users.Add(user1);

            // Create a number of domain object instances here and add them to the list
            return users;
        }
        /// <summary>
        /// Creates a valid, transient User; typical of something retrieved back from a form submission
        /// </summary>
        private User CreateTransientUser()
        {
            User user = new User() {
                UserName = "******",
                Password = "******"
            };

            return user;
        }
        private User CreateTransientUser()
        {
            User user = new User()
            {
                UserName = "******",

            };

            return user;
        }