Ejemplo n.º 1
0
 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"));
     }
 }
Ejemplo n.º 2
0
 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"));
     }
 }
Ejemplo n.º 3
0
        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"));
            }
        }
Ejemplo n.º 4
0
 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"));
     }
 }
Ejemplo n.º 5
0
 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"));
     }
 }
Ejemplo n.º 6
0
 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"));
     }
 }
Ejemplo n.º 7
0
 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"));
     }
 }