public ActionResult ProfileView() { try { if (Session["Id"] != null) { UserDAO dao = new UserDAO(); User u = dao.SearchById(int.Parse(Session["Id"].ToString())); CountryDAO cdao = new CountryDAO(); LanguageDAO ldao = new LanguageDAO(); CartDAO cardao = new CartDAO(); if (Session["Id"] != null) { ViewBag.Cart = cardao.SearchCartUser(int.Parse(Session["Id"].ToString())); } ViewBag.User = u; ViewBag.Country = cdao.List(); ViewBag.Lang = ldao.List(); ViewBag.UserCountry = cdao.SearchById(u.CountryId); return(View()); } return(RedirectToAction("../Home/Index")); } catch { return(RedirectToAction("Index", "Home")); } }
public ActionResult Register() { try { UserDAO dao = new UserDAO(); CountryDAO cdao = new CountryDAO(); LanguageDAO ldao = new LanguageDAO(); ViewBag.Class = ""; ViewBag.User = new User(); ViewBag.Country = cdao.List(); ViewBag.Lang = ldao.List(); return(View()); } catch { return(RedirectToAction("Index", "Home")); } }
public ActionResult Validate(User user) { try { if (ModelState.IsValid) { if (user.Password.Length > 4) { if (user.BirthDate <= DateTime.Now && user.BirthDate.Year >= 1900) { UserDAO dao = new UserDAO(); if (!dao.IsUnique(user)) { user.CrtDate = DateTime.Now; user.Picture = "../../../media/default/default-user.png"; dao.Add(user); return(RedirectToAction("Index", "Home")); } ModelState.AddModelError("user.NotUniq", "Username Already been used"); } else { ModelState.AddModelError("user.BirthNA", "Your birth Date is not acceptable"); } } else { ModelState.AddModelError("user.Password4", "Your password needs to be at least 5 characters"); } } CountryDAO cdao = new CountryDAO(); LanguageDAO ldao = new LanguageDAO(); ViewBag.User = user; ViewBag.Class = "alert alert-danger"; ViewBag.Country = cdao.List(); ViewBag.Lang = ldao.List(); return(View("Register")); } catch { return(RedirectToAction("Index", "Home")); } }
public ActionResult Index() { try { if (Session["ModId"] != null) { LanguageDAO dao = new LanguageDAO(); UserDAO udao = new UserDAO(); User u = udao.SearchById(int.Parse(Session["Id"].ToString())); ViewBag.User = u; ViewBag.Lang = new Language(); ViewBag.Langs = dao.List(); return(View()); } return(RedirectToAction("../Home/Index")); } catch { return(RedirectToAction("Index", "Home")); } }
public ActionResult ChangePassword(string cpsw, string npsw) { try { UserDAO dao = new UserDAO(); User u = dao.SearchById(int.Parse(Session["Id"].ToString())); if (cpsw != null && npsw != null && cpsw != npsw && u.Password == cpsw) { if (npsw.Length > 4) { u.Password = npsw; dao.Update(); return(RedirectToAction("ProfileView")); } else { ModelState.AddModelError("user.Password4", "Your password needs to be at least 5 characters"); } } else { ModelState.AddModelError("user.PasswordDM", "Your password don't match"); } User u2 = dao.SearchById(int.Parse(Session["Id"].ToString())); CountryDAO cdao = new CountryDAO(); LanguageDAO ldao = new LanguageDAO(); ViewBag.User = u2; ViewBag.Country = cdao.List(); ViewBag.UserCountry = cdao.SearchById(u.CountryId); ViewBag.Lang = ldao.List(); //result = "Error"; //return Json(result, JsonRequestBehavior.AllowGet); return(View("ProfileView")); } catch { return(RedirectToAction("Index", "Home")); } }