public async Task <IActionResult> Create(UserRegistrationModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new User
                {
                    UserName    = model.Email,
                    Email       = model.Email,
                    FirstName   = model.FirstName,
                    LastName    = model.LastName,
                    PhoneNumber = model.PhoneNumber,
                };
                var result = await _userManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    foreach (var error in result.Errors)
                    {
                        ModelState.AddModelError(string.Empty, error.Description);
                    }
                    await _userManager.AddToRoleAsync(user, "Visitor");

                    return(RedirectToAction("ManagerUsers", "ManageUser", new { Areas = "Admin" }));
                }
            }
            return(View(model));
        }
        public async Task <IActionResult> Register(UserRegistrationModel userModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(userModel));
            }

            var user = _mapper.Map <User>(userModel);

            var result = await _userManager.CreateAsync(user, userModel.Password);

            if (!result.Succeeded)
            {
                foreach (var error in result.Errors)
                {
                    ModelState.TryAddModelError(error.Code, error.Description);
                }

                return(View(userModel));
            }
            var token = await _userManager.GenerateEmailConfirmationTokenAsync(user);

            var confirmationLink = Url.Action(nameof(ConfirmEmail), "Account", new { token, email = user.Email }, Request.Scheme);

            var message = new Message(new string[] { user.Email }, "Confirmation email link", confirmationLink, null);
            await _emailSender.SendEmailAsync(message);

            await _userManager.AddToRoleAsync(user, "Visitor");

            return(RedirectToAction(nameof(SuccessRegistration)));
        }
Beispiel #3
0
        public async void Register(UserRegistrationModel registerUser)
        {
            var user = new User(registerUser.Email, registerUser.Location, registerUser.Web, registerUser.Bio, registerUser.UserId);
            await _userDbContext.AddAsync(user);

            await _userDbContext.SaveChangesAsync();
        }
        public async Task <IActionResult> Register(UserRegistrationModel model)
        {
            if (ModelState.IsValid)
            {
                var username = _context.Users.Where(p => p.UserUsername == model.UserUsername).FirstOrDefault();
                if (username != null)
                {
                    ViewBag.Message = "Böyle bir kullanıcı var başka bir kullanıcı adı giriniz.";
                    return(View());
                }
                else
                {
                    Users user = new Users
                    {
                        UserEmail        = model.UserEmail,
                        UserFullname     = model.UserFullname,
                        UserPasswd       = model.UserPasswd,
                        UserUsername     = model.UserUsername,
                        UserJob          = model.UserJob,
                        UserPhone        = model.UserPhone,
                        UserCity         = model.UserCity,
                        UserNeighborhood = model.UserNeighborhood,
                    };
                    _context.Add(user);
                    await _context.SaveChangesAsync();
                }
            }

            return(RedirectToAction(nameof(LoginController.Index), "Login"));
        }
 private void AssertUser(UserRegistrationModel model, User user)
 {
     Assert.AreEqual(model.LastName, user.Surname);
     Assert.AreEqual(model.City, user.Address.AddressLine3);
     Assert.AreEqual(model.SecurityQuestionsAndAnswers.Length, user.SecurityQuestions.Count());
     Assert.AreEqual(ExpectedHash(model.Password), user.Password.HashedPassword);
 }
        public IActionResult Register(string returnUrl = null)
        {
            ViewData["ReturnUrl"] = returnUrl;
            UserRegistrationModel userRegistrationModel = new UserRegistrationModel();

            return(View());
        }
Beispiel #7
0
        public IActionResult GetEditPartial(int userID)
        {
            try
            {
                var user = _dbContext.Users.Single(x => x.ID == userID);

                var userData = new UserRegistrationModel
                {
                    CreatedBy      = user.CreatedBy,
                    CreatedOn      = user.CreatedOn,
                    FirstName      = user.FirstName,
                    ID             = user.ID,
                    IsActive       = user.IsActive,
                    IsAdmin        = user.IsAdmin,
                    LastModifiedBy = user.LastModifiedBy,
                    LastModifiedOn = user.LastModifiedOn,
                    LastName       = user.LastName,
                    UserName       = user.UserName
                };
                return(PartialView("_editUserPartial", userData));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("Error", ex.Message);
                return(View("_editUserPartial"));
            }
        }
        public async Task <IActionResult> Register(UserRegistrationModel userModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(userModel));
            }

            //var user = _mapper.Map<User>(userModel);
            var user = new User
            {
                UserName = userModel.Email,
                Name     = userModel.Name,
                Email    = userModel.Email,
                CarNo    = userModel.CarNo,
                CarType  = userModel.CarType,
                Colour   = userModel.CarColor
            };

            var result = await _userManager.CreateAsync(user, userModel.Password);

            if (!result.Succeeded)
            {
                foreach (var error in result.Errors)
                {
                    ModelState.TryAddModelError(error.Code, error.Description);
                }

                return(View(userModel));
            }

            await _userManager.AddToRoleAsync(user, "Visitor");

            return(RedirectToAction(nameof(AccountController.Login), "Account"));
        }
Beispiel #9
0
        public async Task <IdentityResult> Register(UserRegistrationModel model)
        {
            var user   = _mapper.Map <User>(model);
            var result = await _unit.UserManager.CreateAsync(user, model.Password);

            return(result);
        }
Beispiel #10
0
        public async void RegisterButton()
        {
            try
            {
                UserRegistrationModel urm = new UserRegistrationModel
                {
                    FirstName    = FirstName,
                    LastName     = LastName,
                    UserName     = UserName,
                    TCIDNumber   = TCIDNumber,
                    PhoneNumber  = PhoneNumber,
                    EmailAddress = EmailAddress,
                    Address      = Address,
                    Password     = Password
                };
                await _apiHelper.RegisterUser(urm);

                StatusMessage = ("Your account has been created. You are being redirected...");


                var tempAuthenticatedUser = await _apiHelper.Authenticate(urm.UserName, urm.Password);

                _loggedInUserModel.GetData(await _userEnd.GetLoggedInUserInfo(tempAuthenticatedUser.Access_Token));

                await _eventAggregator.PublishOnUIThreadAsync(new LogOnEvent());
            }

            catch (Exception ex)
            {
                StatusMessage = ex.Message;
            }
        }
        public async Task <IActionResult> Register(UserRegistrationModel userModel)
        {
            if (!ModelState.IsValid)
            {
                // return View(userModel);
                return(NoContent());
            }

            var user = _mapper.Map <User>(userModel);

            var result = await _userManager.CreateAsync(user, userModel.Password);

            if (!result.Succeeded)
            {
                foreach (var error in result.Errors)
                {
                    ModelState.TryAddModelError(error.Code, error.Description);
                }

                // return (userModel);
                return(NoContent());
            }

            await _userManager.AddToRoleAsync(user, "Visitor");

            return(NoContent());
            // return RedirectToAction(nameof(HomeController.Index), "Home");
        }
        public async Task <IActionResult> Register(UserRegistrationModel userModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(userModel));
            }

            var user = new User
            {
                FirstName = userModel.FirstName,
                LastName  = userModel.LastName,
                UserName  = userModel.Email,
                Email     = userModel.Email
            };

            var result = await _userManager.CreateAsync(user, userModel.Password);

            if (!result.Succeeded)
            {
                foreach (var error in result.Errors)
                {
                    ModelState.TryAddModelError(error.Code, error.Description);
                }

                return(View(userModel));
            }

            await _userManager.AddToRoleAsync(user, "Visitor");

            return(RedirectToAction(nameof(HomeController.Index), "Home"));
        }
        public async Task <IActionResult> Post(UserRegistrationModel registrationModel)
        {
            if (string.IsNullOrWhiteSpace(registrationModel.Username) || string.IsNullOrWhiteSpace(registrationModel.Password))
            {
                return(BadRequest());
            }
            var alreadyExist = await _context.Users.AnyAsync(u => u.UserName.Equals(registrationModel.Username));

            if (alreadyExist)
            {
                return(BadRequest());
            }
            await _context.Users.AddAsync(new UserEntity
            {
                Guid         = Guid.NewGuid(),
                UserName     = registrationModel.Username,
                PasswordHash = PasswordUtil.HashPassword(registrationModel.Password),
                Role         = Role.Customer,
                Email        = registrationModel.Email
            });

            await _context.SaveChangesAsync();

            return(Ok());
        }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var obj = JObject.Load(reader);
            RegistrationModelBase model;

            var type = obj["Type"];
            if (type == null)
            {
                obj["Type"] = ((IdentityTypes)0).ToString();
                type = obj["Type"];
            }

            string modelType = type.Value<string>();
            IdentityTypes actualType;
            if (!Enum.TryParse<IdentityTypes>(modelType, out actualType))
                throw new NotSupportedException("Invalid AssetType Provided");

            switch (actualType)
            {
                case IdentityTypes.USER:
                    model = new UserRegistrationModel();
                    break;
                case IdentityTypes.ENTERPRISE:
                    model = new EnterpriseUserRegistrationModel();
                    break;
                default:
                    model = new AssetRegistrationModel();
                    break;
            }

            serializer.Populate(obj.CreateReader(), model);
            return model;
        }
        /*
         * public ActionResult About()
         * {
         *  ViewBag.Message = "Your application description page.";
         *
         *  return View();
         * }
         *
         * public ActionResult Contact()
         * {
         *  ViewBag.Message = "Your contact page.";
         *
         *  return View();
         * }
         */
        #endregion
        public ActionResult SignUp()
        {
            ViewBag.Message = "Реєстрація користувача";
            UserRegistrationModel user = new UserRegistrationModel();

            return(View());
        }
        public ActionResult Register(UserRegistrationModel model)
        {
            // validation of the model
            bool isModelValid = Validate(model);


            if (isModelValid)
            {
                // create user input dto
                var uid = new UserInputDto
                {
                    User = new UserDto()
                    {
                        Name       = model.Name,
                        Username   = model.Username,
                        Occupation = model.Occupation,
                        Password   = model.Password.HashMd5()
                    }
                };

                // send registeration request
                var response = Services.AuthService.Register(uid);

                if (response != null)
                {
                    return(RedirectToAction("Index"));
                }
            }

            return(RedirectToAction("Register"));
        }
Beispiel #17
0
        public JsonResult Verify(UserRegistrationModel user, string code)
        {
            var newuser = new UserModel {
                Email = user.Email, Password = user.Password, PhoneNumber = user.PhoneNumber
            };

            try
            {
                //Todo: Call service to verify
                var validcode = true;

                if (validcode)
                {
                    //Todo: Save to db, save in memory for now.
                    //_context.Add(newuser);
                    //await _context.SaveChangesAsync();
                    var createduser = _userservice.CreateUser(newuser);

                    //Start Session
                    HttpContext.Session.SetString("SessionState", createduser.Email);

                    return(Json(new { HasError = false, Email = createduser.Email, Code = code }));
                }
                else
                {
                    return(Json(new { HasError = true, ErrorMessage = "Invalid login attempt." }));
                }
            }
            catch
            {
                //Todo: Log exception, Audit event
                return(Json(new { HasError = true, ErrorMessage = "Application Exception. Please try again." }));
            }
        }
Beispiel #18
0
 public IActionResult RegisterUser([FromBody] UserRegistrationModel userRegistration)
 {
     if (userRegistration == null ||
         string.IsNullOrEmpty(userRegistration.Email) ||
         string.IsNullOrEmpty(userRegistration.Username) ||
         string.IsNullOrEmpty(userRegistration.Token) ||
         string.IsNullOrEmpty(userRegistration.Password))
     {
         throw new MissingParameterException();
     }
     if (userRegistration?.Email?.Length > Limits.MAX_EMAIL_ADDRESS)
     {
         throw new InputValueTooLargeException();
     }
     if (userRegistration?.Username?.Length > Limits.MAX_USERNAME)
     {
         throw new InputValueTooLargeException();
     }
     if (userRegistration?.Token?.Length > Limits.MAX_REGISTER_CODE)
     {
         throw new InputValueTooLargeException();
     }
     if (userRegistration?.Password?.Length > Limits.MAX_PASSWORD)
     {
         throw new InputValueTooLargeException();
     }
     PwdManService.RegisterUser(userRegistration);
     return(new JsonResult(true));
 }
Beispiel #19
0
        public ActionResult Index(UserRegistrationModel model)
        {
            var recaptchaHelper = this.GetRecaptchaVerificationHelper();

            if (String.IsNullOrEmpty(recaptchaHelper.Response))
            {
                ModelState.AddModelError("", "Captcha answer cannot be empty.");
                return(View(model));
            }

            var recaptchaResult = recaptchaHelper.VerifyRecaptchaResponse();

            if (!recaptchaResult.Success)
            {
                foreach (var err in recaptchaResult.ErrorCodes)
                {
                    ModelState.AddModelError("", err);
                }
            }
            else
            {
                return(RedirectToAction("Welcome"));
            }

            return(View(model));
        }
        public async Task <IActionResult> Register(UserRegistrationModel userModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(userModel));
            }

            var client = _mapper.Map <Client>(userModel);

            var result = await _userManager.CreateAsync(client, userModel.Password);

            if (!result.Succeeded)
            {
                foreach (var error in result.Errors)
                {
                    ModelState.TryAddModelError(error.Code, error.Description);
                }
                return(View(userModel));
            }

            await _userManager.AddToRoleAsync(client, "Visitor");

            //NOT SURE WHAT TO DO HERE
            return(null);
        }
Beispiel #21
0
        public async Task <IActionResult> Register(UserRegistrationModel userModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(userModel)); // daca modelul nu este valid se returneaza acelasi view cu modelul invalidat
            }

            var user = _mapper.Map <ApplicationUser>(userModel);

            var result = await _userManager.CreateAsync(user, userModel.Password); // createAsync are o parolă, execută verificări suplimentare ale utilizatorului și returnează un rezultat.

            if (!result.Succeeded)                                                 //daca se valideaza mapam modelul de inregistrare la utilizator
            {
                foreach (var error in result.Errors)
                {
                    ModelState.TryAddModelError(error.Code, error.Description);
                }

                return(View(userModel));
            }

            if (userModel.esteAdmin)
            {
                await _userManager.AddToRoleAsync(user, "Administrator");

                return(RedirectToAction("Register", "Account"));
            }
            else
            {
                await _userManager.AddToRoleAsync(user, "User");

                return(RedirectToAction("Register", "Account"));
            }
        }
        public async Task <IActionResult> Register(UserRegistrationModel registrationModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(registrationModel));
            }

            var user = _mapper.Map <User>(registrationModel);

            var result = await _userManager.CreateAsync(user, registrationModel.Password);

            if (!result.Succeeded)
            {
                foreach (var error in result.Errors)
                {
                    ModelState.TryAddModelError(error.Code, error.Description);
                }

                return(View(registrationModel));
            }

            var token = await _userManager.GenerateEmailConfirmationTokenAsync(user);

            var callbackUrl = Url.Action(nameof(ConfirmEmail), "Account", new { token, email = user.Email }, Request.Scheme);
            var message     = $"To confirm email click <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>here</a>";
            await _emailSender.SendEmailAsync(user.Email, "Email confirmation", message);

            await _userManager.AddToRoleAsync(user, "Visitor");

            return(RedirectToAction(nameof(SuccessRegistration)));
        }
 public IActionResult Register(UserRegistrationModel userModel)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(View(userModel));
         }
         List <Account> lstacc   = AccountRes.GetAll();
         int            countAcc = 0;
         for (int i = 0; i < lstacc.Count; i++)
         {
             if (lstacc[i].username == userModel.Username)
             {
                 countAcc = 1;
             }
         }
         if (countAcc == 1)
         {
             ModelState.AddModelError("1", "UserName already exists! Please try another.");
         }
         else
         {
             int resultAcc     = AccountRes.InsertRegisterAccount(userModel.Username, userModel.Password);
             int resultDetails = AccountRes.InsertRegisterDetails(userModel.Username, userModel.FullName,
                                                                  userModel.Email, userModel.PhoneNumber, userModel.Address, resultAcc);
             return(RedirectToAction("Index", "HomeDrugstore"));
         }
     }
     catch (Exception ex)
     {
         Console.Write(ex);
     }
     return(View());
 }
        public async Task <IActionResult> RegisterStaff(UserRegistrationModel users)
        {
            if (!ModelState.IsValid)
            {
                return(View(users));
            }

            //var user = _mapper.Map<User>(userModel);
            var user = new User
            {
                UserName = users.Email,
                Name     = users.Name,
                Email    = users.Email,
            };

            var result = await _userManager.CreateAsync(user, users.Password);

            if (!result.Succeeded)
            {
                foreach (var error in result.Errors)
                {
                    ModelState.TryAddModelError(error.Code, error.Description);
                }

                return(View(users));
            }

            await _userManager.AddToRoleAsync(user, "Staff");

            return(RedirectToAction(nameof(AfterloginController.Afterloginhome), "Afterlogin"));
        }
        public async Task <IActionResult> OnPost(UserRegistrationModel model)
        {
            if (ModelState.IsValid)
            {
                var identityUser = new IdentityUser
                {
                    Email    = model.Email,
                    UserName = model.Login
                };

                var result = await _userManager.CreateAsync(identityUser, model.Password);

                if (result.Succeeded)
                {
                    ViewData["OnPostSuccess"] = "OnPostMethodSuccess";
                    return(RedirectToPage("/index"));
                }
                else
                {
                    ViewData["OnPostSuccess"] = "OnPostMethodUserManagerError";
                    return(Page());
                }
            }

            return(Page());
        }
Beispiel #26
0
        public IHttpActionResult Register(UserRegistrationModel userRegistrationModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            User user = new User()
            {
                UserName = userRegistrationModel.UserName,
                Password = userRegistrationModel.Password,
                Email    = userRegistrationModel.Email,
                Phone    = userRegistrationModel.Phone
            };
            User result = _userRepository.RegisterUser(user);

            UnitOfWork.Save();


            IHttpActionResult errorResult = GetErrorResult(result);

            if (errorResult != null)
            {
                return(errorResult);
            }

            return(Ok());
        }
        public async Task <IActionResult> Register([FromBody] UserRegistrationModel registrationModel)
        {
            if (ModelState.IsValid)
            {
                UserResultModel authResponse = await identityService.RegisterAsync(registrationModel.Email, registrationModel.Password);

                if (!authResponse.Success)
                {
                    FailedResponseModel badResponse = new FailedResponseModel()
                    {
                        Errors = authResponse.Errors
                    };

                    return(BadRequest(badResponse));
                }

                UserSuccessResponseModel successResponse = new UserSuccessResponseModel()
                {
                    Token = authResponse.Token
                };

                return(Ok(successResponse));
            }

            return(BadRequest(new FailedResponseModel {
                Errors = ModelState.Values.SelectMany(x => x.Errors.Select(y => y.ErrorMessage))
            }));
        }
Beispiel #28
0
        public async Task <IActionResult> Register(UserRegistrationModel model, string returnUrl = null)
        {
            if (ModelState.IsValid)/*Phần đăng ký cho User*/
            {
                //var user = _mapper.Map<User>(model);
                // Copy data from RegisterViewModel to IdentityUser
                var user = new User
                {
                    UserName = model.Email,
                    Email    = model.Email
                };

                // Store user data in AspNetUsers database table
                var result = await _userManager.CreateAsync(user, model.Password);


                if (result.Succeeded)
                {
                    await _SinInManager.SignInAsync(user, isPersistent : false);

                    return(RedirectToAction("Index", "Home"));
                }


                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError(string.Empty, error.Description);
                }
                await _userManager.AddToRoleAsync(user, "Visitor");
            }
            return(View(model));
        }
Beispiel #29
0
        public async Task <IHttpActionResult> Registrate(UserRegistrationModel userModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            if (!await _userService.IsExistsAsync(userModel.Email))
            {
                try
                {
                    UserDTO user = _mapper.Map <UserDTO>(userModel);
                    await _userService.CreateUserAsync(user);

                    return(Ok("You were registered"));
                }
                catch (Exception ex)
                {
                    return(InternalServerError(ex));
                }
            }
            else
            {
                return(BadRequest("This user is already created"));
            }
        }
        public ViewResult Register(UserRegistrationModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                User existUser = repository.Users.FirstOrDefault(item => item.Username.ToLower() == model.Username.ToLower());
                if (existUser == null)
                {
                    User user = new User();
                    user.Username = model.Username;
                    user.Password = model.Password;
                    user.Email    = model.Email;

                    repository.SaveUser(user);

                    //int UserId = user.ID;


                    ViewBag.returnUrl = returnUrl;
                    return(View("RegistrationCompleted"));
                }
                else
                {
                    ModelState.AddModelError("", "An User with same User name already exists");
                    //
                    return(View(model));
                }
            }
            //
            // If we got this far, something failed, redisplay form!
            //
            return(View(model));
        }
Beispiel #31
0
        public void Register(UserRegistrationModel userRegistrationModel)
        {
            var user = _mapper.Map <User>(userRegistrationModel);

            user.UserType = 2;
            _capstoneContext.Add(user);
        }
Beispiel #32
0
 //FIXME: This should be segregated, having the whole usermodel coming here is okay, but not good
 public UserProfile(UserRegistrationModel userModel)
 {
     this.FirstName = userModel.FirstName;
     this.LastName = userModel.LastName;
     this.Gender = userModel.Gender;
     this.Age = userModel.Age;
     this.InterestedLocalities = userModel.InterestedLocalities;
 }
Beispiel #33
0
        public User(UserRegistrationModel model, UserProfile profile) : this(model)
        {
            this.Roles = new List<string>();
            Roles.Add(RoleNames.ROLE_USER);

            //FIXME: This has been done because UserModel is just the same here
            //If we decide to expose different models for different clients things would be a bit different
            this.Profile = profile;
        }
        public ActionResult UserRegister(UserRegistrationModel model)
        {
            AuthenticationProvider ap = new AuthenticationProvider();
            if (ap.LoginMach(model.Login))
            {
                ModelState.AddModelError("Login", "Login must be unique");
                return View("UserRegister", model);
            }
            UserManager um = new UserManager();
            UserRegistrationModel urm = new UserRegistrationModel();
            if (ModelState.IsValid)
            {

                um.Insert(GetUser(model));
            }

            return View("UserRegister", urm);
        }
Beispiel #35
0
        public async Task Test_RegisterUser_With_Single_Interested_Locality()
        {
            accountManagerMock = new Mock<AccountManager>(userStoreMock.Object);

            IdentityResult identityResult = new IdentityResult(null);
            accountManagerMock.Setup(x => x.CreateAsync(It.IsAny<User>())).ReturnsAsync(identityResult);

            var accountContext = new AccountContext(
                dbContextMock.Object,
                mailServiceMock.Object,
                accountManagerMock.Object,
                blobServiceMock.Object,
                jobManagerMock.Object);

            var registerModel = new UserRegistrationModel()
            {
                UserName = "******",
                Type = IdentityTypes.USER,
                Password = "******",
                ConfirmPassword = "******",
                Email = "*****@*****.**",
                PhoneNumber = "+88017100000",
                InterestedLocalities = new List<string>() {
                    "TestLocality"
                }
            };

            var result = await accountContext.RegisterUser(registerModel);

            Assert.NotNull(result.User);
            Assert.AreEqual("testUsername", result.User.UserName);
            Assert.AreEqual(IdentityTypes.USER, result.User.Type);
            Assert.AreEqual("*****@*****.**", result.User.Email);
            Assert.AreEqual(false, result.User.EmailConfirmed);
            Assert.AreEqual("+88017100000", result.User.PhoneNumber);
            Assert.AreEqual(false, result.User.PhoneNumberConfirmed);
            Assert.NotNull(result.User.Profile);
            Assert.AreEqual(typeof(UserProfile), result.User.Profile.GetType());
            Assert.NotNull((result.User.Profile as UserProfile).InterestedLocalities);
            Assert.AreEqual(1, (result.User.Profile as UserProfile).InterestedLocalities.Count);
            Assert.AreEqual("TestLocality", (result.User.Profile as UserProfile).InterestedLocalities.First());
        }
 public ActionResult UserRegister()
 {
     UserRegistrationModel urm = new UserRegistrationModel();
     return View("UserRegister", urm);
 }
 private User GetUser(UserRegistrationModel model)
 {
     User user = new User
     {
         Name = model.Name,
         Surname = model.Surname,
         MiddleName = model.Middlename,
         Phone = model.Phone,
         Login = model.Login,
         Password = model.Password,
         Nationality = model.Nationality
     };
     return user;
 }
Beispiel #38
0
 protected User(UserRegistrationModel model, UserProfile profile, string role) : this(model, profile)
 {
     this.Roles = this.Roles ?? new List<string>();
     Roles.Add(role);
 }