Exemplo n.º 1
0
        //
        // GET: /Account/FakeUnlockMail
        public ActionResult UnlockUser(int id)
        {
            user user = userRepository.Get(id);

            //handle error
            if (user == null)
            {
                return RedirectToAction("Error", "Home", new { msg = "User object was null..." });
            }

            UserViewModel model = new UserViewModel(user);
            //activate account
            try
            {
                model.is_active = true;
                model.ApplyChanges();
                userRepository.Save();
            }
            catch (Exception e)
            {
                return RedirectToAction("Error", "Home", new { msg = "Exception caught while saving data: " + e.Message });
            }

            ViewBag.user = model;

            return View();
        }
Exemplo n.º 2
0
        public ActionResult Register(UserViewModel model)
        {
            if (ModelState.IsValid)
            {

                try
                {
                    model.ApplyChanges();

                    //if no exception was thrown, check if the user creation was successfuland redirect
                    user new_user = userRepository.GetByUsername(model.username);
                    if (new_user != null)
                    {
                        return RedirectToAction("FakeUnlockMail", "User", new { id = new_user.id });
                    }
                }
                catch (Exception)
                {
                    return RedirectToAction("Error", "Home", new { msg = "Exception adding user..." });
                }
            }
            // If we got this far, something failed, redisplay form
            return View(model);
        }