Пример #1
0
 public ActionResult Edit(ChangeMemberModel edittedMember)
 {
     try
     {
         MemberManager memberManager = new MemberManager();
         memberManager.Change(edittedMember);
         return RedirectToAction("Index", "Home");
     }
     catch
     {
         ModelState.AddModelError("", "Could not save changes.");
         return View();
     }
 }
Пример #2
0
        public ActionResult ForgotPassword(ResetMemberPasswordModel member)
        {
            try
            {
                Member currentMember = db.Members.Single(m => m.Username == member.Username);

                MemberManager memberManager = new MemberManager();
                memberManager.ResetPassword(currentMember);

                currentMember.LastActivity = DateTime.Now;
                db.SaveChanges();
            }
            catch (Exception)
            {
                ModelState.AddModelError("", "Username does not exist.");
            }
            return View();
        }
Пример #3
0
        public ActionResult Register(NewMemberModel newMember)
        {
            try
                {
                    if (ModelState.IsValid)
                    {
                        MemberManager memberManager = new MemberManager();
                        if (!memberManager.UsernameExist(newMember.Username))
                        {
                            var registeredMember = memberManager.Add(newMember);
                            FormsAuthentication.SetAuthCookie(registeredMember.Username, false);

                            return RedirectToAction("Welcome", "Home");
                        }
                        else
                        {
                            ModelState.AddModelError("", "Username already taken.");

                        }
                    }
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("", e.ToString());
                }

                return View(newMember);
        }