Exemplo n.º 1
0
        public ActionResult Create(CreateOrUpdatePersonCommand personInput)
        {
            if (ModelState.IsValid)
            {
                var personService = new PersonService();
                personInput.isSuccess = personService.CreatePerson(personInput);
                return(View("SuccessPage"));
            }

            return(View(personInput));
        }
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            CreateOrUpdatePersonCommand person = (CreateOrUpdatePersonCommand)validationContext.ObjectInstance;

            PersonService personService = new PersonService();

            if (personService.IsUsernameDuplicate(person.username))
            {
                return(new ValidationResult("Username is already taken."));
            }

            return(ValidationResult.Success);
        }
Exemplo n.º 3
0
        public ActionResult Create()
        {
            CreateOrUpdatePersonCommand personInput = new CreateOrUpdatePersonCommand();

            return(View(personInput));
        }