예제 #1
0
        public ActionResult Register(RegistrationViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return View("Index", model);
            }

            var user = Session.Query<User>().Where(x => x.Username == model.Username || x.Email == model.Email).FirstOrDefault();

            if (user != null)
            {
                ModelState.AddModelError("Unique", "Username and e-mail must be unique.");
                return View("Index", model);
            }

            var newUser = new User(Guid.NewGuid().ToString(), model.Username, model.Password, model.Email);
            newUser.Avatar = Session.Load<Avatar>(Avatar.DefaultAvatarId);
            MyPhoto.Web.Library.Installers.Search.AddOrUpdate(newUser);
            Session.Save(newUser);
            return RedirectToAction("Index", "Home");
        }
예제 #2
0
 public ActionResult Index()
 {
     RegistrationViewModel model = new RegistrationViewModel();
     return View(model);
 }