Esempio n. 1
0
        public async Task <IActionResult> CreateRealtor(CreateRealtorViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser
                {
                    UserName = model.Email,
                    Email    = model.Email
                };
                var result = await userManager.CreateAsync(user, "Realtor@1");

                if (result.Succeeded)
                {
                    if (model.IsMvp)
                    {
                        await userManager.AddToRoleAsync(user, "Realtor");
                    }
                    var message = realtorRepo.CreateRealtor(model);
                    return(RedirectToAction(nameof(Realtors)));
                }

                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError(string.Empty, error.Description);
                }
                ;
            }
            return(View());
        }
        public async Task <IActionResult> CreateRealtor(CreateRealtorViewModel model)
        {
            if (ModelState.IsValid)
            {
                var message = await _realtorRepo.CreateRealtor(model);

                return(RedirectToAction(nameof(Realtors)));
            }
            return(View());
        }