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 Checkout() { try { CartDAO cardao = new CartDAO(); IList <Cart> cart = cardao.GetUserCart(int.Parse(Session["Id"].ToString())); if (Session["Id"] != null && cart.Count() != 0) { UserDAO udao = new UserDAO(); CountryDAO cdao = new CountryDAO(); User u = udao.SearchById(int.Parse(Session["Id"].ToString())); ViewBag.User = u; ViewBag.CountryUser = cdao.SearchById(u.CountryId); ViewBag.Cart = cardao.SearchCartUser(int.Parse(Session["Id"].ToString())); ViewBag.FullCart = cart; return(View()); } else { return(RedirectToAction("../Home/Index")); } } catch { return(RedirectToAction("../Home/Index")); } }
public ActionResult ProfileView() { try { if (Session["DevId"] != null) { DeveloperDAO dao = new DeveloperDAO(); ApplicationDAO appdao = new ApplicationDAO(); UserDAO udao = new UserDAO(); CountryDAO cdao = new CountryDAO(); Developer dev = dao.SearchById(int.Parse(Session["DevId"].ToString())); User u = udao.SearchById(int.Parse(Session["Id"].ToString())); CartDAO cardao = new CartDAO(); if (Session["Id"] != null) { ViewBag.Cart = cardao.SearchCartUser(int.Parse(Session["Id"].ToString())); } ViewBag.DevGames = appdao.GetDevGames(dev.Id); ViewBag.Dev = dev; ViewBag.User = u; ViewBag.CountryUser = cdao.SearchById(u.CountryId); return(View()); } else { return(RedirectToAction("../Home/Index")); } } catch { return(RedirectToAction("Index", "Home")); } }
public ActionResult Remove(int id) { try { if (Session["ModId"] != null) { CountryDAO dao = new CountryDAO(); Country c = dao.SearchById(id); dao.Remove(c); return(RedirectToAction("Index")); } else { return(RedirectToAction("../Home/Index")); } } catch { return(RedirectToAction("Index", "Home")); } }
public ActionResult EditConfirm(Country country) { try { if (Session["ModId"] != null) { CountryDAO dao = new CountryDAO(); Country g = dao.SearchById(country.Id); g.Name = country.Name; dao.Update(); return(RedirectToAction("Index")); } else { 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")); } }
public ActionResult Edit(int id) { try { if (Session["ModId"] != null) { CountryDAO dao = new CountryDAO(); UserDAO udao = new UserDAO(); User u = udao.SearchById(int.Parse(Session["Id"].ToString())); ViewBag.User = u; ViewBag.Country = dao.SearchById(id); return(View()); } else { return(RedirectToAction("../Home/Index")); } } catch { return(RedirectToAction("Index", "Home")); } }