Example #1
0
        public ActionResult Register(RegisterViewModel model)
        {
            if (!ModelState.IsValid)
                return View(model);

            var company = companyService.GetById(model.CompanyId);

            var user = new User();

            user.Company = company;
            user.FirstName = model.FirstName;
            user.LastName = model.LastName;
            user.Email = model.Email;
            user.Password = userService.HashPassword(model.ConfirmPassword);
            user.Role = UserRoles.Member;

            userService.Add(user);

            FormsAuthentication.SetAuthCookie(model.Email, false);

            return RedirectToAction("Index", "Home");
        }
Example #2
0
        public ActionResult Register()
        {
            var companies = companyService.GetAll().ToList();

            var model = new RegisterViewModel(companies);

            return View(model);
        }