Ejemplo n.º 1
0
 public ActionResult Moderator(int id)
 {
     try
     {
         if (Session["ModId"] != null)
         {
             ApplicationDAO dao  = new ApplicationDAO();
             UserDAO        udao = new UserDAO();
             DeveloperDAO   ddao = new DeveloperDAO();
             User           u    = udao.SearchById(int.Parse(Session["Id"].ToString()));
             ViewBag.User          = u;
             ViewBag.Apps          = dao.SearchByType(id);
             ViewBag.AppsToApprove = dao.AppsToApprove();
             ViewBag.Devs          = ddao.List();
             return(View());
         }
         else
         {
             return(RedirectToAction("../Home/Index"));
         }
     }
     catch
     {
         return(RedirectToAction("../Home/Index"));
     }
 }
Ejemplo n.º 2
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.º 3
0
 public ActionResult Product(int id)
 {
     try
     {
         ApplicationDAO dao   = new ApplicationDAO();
         DeveloperDAO   ddao  = new DeveloperDAO();
         ImageDAO       idao  = new ImageDAO();
         UserDAO        udao  = new UserDAO();
         SellItemDAO    sidao = new SellItemDAO();
         Application    app   = dao.SearchById(id);
         Developer      dev   = ddao.SearchById(app.DeveloperId);
         CartDAO        cdao  = new CartDAO();
         PegiDAO        pdao  = new PegiDAO();
         ViewBag.SellItem = false;
         if (Session["Id"] != null)
         {
             ViewBag.Cart     = cdao.SearchCartUser(int.Parse(Session["Id"].ToString()));
             ViewBag.SellItem = sidao.SearchUserApp(int.Parse(Session["Id"].ToString()), id);
             WishlistDAO wdao = new WishlistDAO();
             ViewBag.IsInWish = wdao.IsInWishList(int.Parse(Session["Id"].ToString()), id);
         }
         ViewBag.App     = app;
         ViewBag.Dev     = dev;
         ViewBag.Pegi    = pdao.SearchById(app.PegiId);
         ViewBag.DevUser = udao.SearchByDev(dev.Id);
         ViewBag.Img     = idao.SearchAppImages(id);
         ViewBag.Similar = dao.ListLast10();
         return(View());
     }
     catch
     {
         return(RedirectToAction("../Home/Index"));
     }
 }
Ejemplo n.º 4
0
        public ActionResult Validate(Developer dev)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    DeveloperDAO dao = new DeveloperDAO();
                    dev.NumSoft = 0;
                    dao.Add(dev);
                    Developer devel = dao.AttachDevUser(dev);

                    UserDAO udao = new UserDAO();
                    User    u    = udao.SearchById(int.Parse(Session["Id"].ToString()));
                    u.DeveloperId = devel.Id;
                    udao.Update();
                    Session["DevId"] = u.DeveloperId;
                    return(RedirectToAction("ProfileView", "Developer"));
                }
                ViewBag.Class = "alert alert-danger";
                ViewBag.Dev   = dev;
                return(View("Register"));
            }
            catch
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
Ejemplo n.º 5
0
 public ActionResult Register()
 {
     try
     {
         if (Session["Id"] != null)
         {
             DeveloperDAO dao = new DeveloperDAO();
             ViewBag.Dev   = new Developer();
             ViewBag.Class = "";
             return(View());
         }
         return(RedirectToAction("../Home/Index"));
     }
     catch
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
Ejemplo n.º 6
0
 public ActionResult Moderator()
 {
     try
     {
         if (Session["ModId"] != null)
         {
             DeveloperDAO dao  = new DeveloperDAO();
             UserDAO      udao = new UserDAO();
             User         u    = udao.SearchById(int.Parse(Session["Id"].ToString()));
             ViewBag.User = u;
             ViewBag.Devs = dao.List();
             return(View());
         }
         return(RedirectToAction("../Home/Index"));
     }
     catch
     {
         return(RedirectToAction("../Home/Index"));
     }
 }
Ejemplo n.º 7
0
 public ActionResult Sales()
 {
     try
     {
         if (Session["DevId"] != null)
         {
             DeveloperDAO dao  = new DeveloperDAO();
             UserDAO      udao = new UserDAO();
             SellDAO      sdao = new SellDAO();
             Developer    d    = dao.SearchById(int.Parse(Session["DevId"].ToString()));
             ViewBag.User      = udao.SearchById(int.Parse(Session["Id"].ToString()));
             ViewBag.Dev       = d;
             ViewBag.SaleCount = sdao.DevGet7DaysSells(int.Parse(Session["DevId"].ToString()));
             return(View());
         }
         return(RedirectToAction("Index", "Home"));
     }
     catch
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
Ejemplo n.º 8
0
 public ActionResult Summary()
 {
     try
     {
         if (Session["DevId"] != null)
         {
             DeveloperDAO   dao  = new DeveloperDAO();
             UserDAO        udao = new UserDAO();
             ApplicationDAO adao = new ApplicationDAO();
             ViewBag.User = udao.SearchById(int.Parse(Session["Id"].ToString()));
             Developer d = dao.SearchById(int.Parse(Session["DevId"].ToString()));
             ViewBag.Apps = adao.GetDevGames(d.Id);
             ViewBag.Dev  = d;
             return(View());
         }
         return(RedirectToAction("Index", "Home"));
     }
     catch
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
Ejemplo n.º 9
0
 public ActionResult Login(User user)
 {
     try
     {
         UserDAO dao    = new UserDAO();
         User    u      = dao.Login(user);
         var     result = "";
         if (u != null)
         {
             Session["Id"]       = u.Id;
             Session["Username"] = u.Username;
             if (u.DeveloperId != null)
             {
                 DeveloperDAO ddao = new DeveloperDAO();
                 Developer    d    = ddao.SearchById(int.Parse(u.DeveloperId.ToString()));
                 Session["DevId"] = d.Id;
             }
             if (u.ModeratorId != null)
             {
                 ModeratorDAO mdao = new ModeratorDAO();
                 Moderator    m    = mdao.SearchById(int.Parse(u.ModeratorId.ToString()));
                 Session["ModId"] = m.Id;
             }
             result = "Logged In";
             return(Json(result, JsonRequestBehavior.AllowGet));
             //return RedirectToAction("../Home/Index");
         }
         result = "An error occurred. Try again";
         return(Json(result, JsonRequestBehavior.AllowGet));
         //return RedirectToAction("../Home/Index");
     }
     catch
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
Ejemplo n.º 10
0
        public ActionResult Validate(Application app, IList <HttpPostedFileBase> images, HttpPostedFileBase File, IList <Genre> genres)
        {
            var result = "";

            if (ModelState.IsValid)
            {
                try
                {
                    app.Approved = 0;
                    ApplicationDAO      dao = new ApplicationDAO();
                    Application         uniq = dao.IsUnique(app);
                    DeveloperDAO        ddao = new DeveloperDAO();
                    ImageDAO            idao = new ImageDAO();
                    ApplicationGenreDAO agdao = new ApplicationGenreDAO();
                    Developer           Dev = ddao.SearchById(int.Parse(Session["DevId"].ToString()));
                    bool ImgError = false, FileError = false, AGError = false;
                    if (Dev != null)
                    {
                        if (app.ReleaseDate.Year >= 1900 && app.ReleaseDate.Year <= DateTime.Now.Year + 1)
                        {
                            if (app.Price >= 0 && app.Price <= 1000)
                            {
                                if (uniq == null)
                                {
                                    app.DeveloperId = Dev.Id;
                                    dao             = new ApplicationDAO();
                                    dao.Add(app);
                                    Dev.NumSoft++;
                                    ddao.Update();

                                    Application appreg = dao.GetDevLastGame(Dev.Id);
                                    try
                                    {
                                        foreach (var g in genres)
                                        {
                                            if (g.IsChecked == true)
                                            {
                                                ApplicationGenre ag = new ApplicationGenre();
                                                ag.ApplicationId = appreg.Id;
                                                ag.GenreId       = g.Id;
                                                agdao.Add(ag);
                                            }
                                        }
                                    }
                                    catch
                                    {
                                        AGError = true;
                                    }

                                    try
                                    {
                                        //Images
                                        int count = 0;
                                        foreach (var img in images)
                                        {
                                            string filePath = Guid.NewGuid() + Path.GetExtension(img.FileName);
                                            img.SaveAs(Path.Combine(Server.MapPath("~/media/app"), filePath));
                                            Image i = new Image();
                                            i.Url           = "../../../media/app/" + filePath;
                                            i.UserId        = int.Parse(Session["Id"].ToString());
                                            i.ApplicationId = appreg.Id;
                                            idao.Add(i);
                                            if (count == 0)
                                            {
                                                appreg.ImageUrl = i.Url;
                                                count++;
                                                dao.Update();
                                            }
                                        }
                                        //
                                    }
                                    catch
                                    {
                                        appreg.ImageUrl = "../../../assets/images/game-kingdoms-of-amalur-reckoning-4-500x375.jpg";
                                        dao.Update();
                                        ImgError = true;
                                        result   = result + "Error on Uploading Images, try later";
                                    }
                                    try
                                    {
                                        //File
                                        string filePath2 = Guid.NewGuid() + Path.GetExtension(File.FileName);
                                        if (!Directory.Exists(Server.MapPath("~/apps/appfiles/" + appreg.Id)))
                                        {
                                            Directory.CreateDirectory(Server.MapPath("~/apps/appfiles/" + appreg.Id));
                                        }
                                        File.SaveAs(Path.Combine(Server.MapPath("~/apps/appfiles/" + appreg.Id), filePath2));
                                        appreg.Archive = "../../../apps/appfiles/" + appreg.Id + "/" + filePath2;
                                        dao.Update();
                                        //
                                    }
                                    catch
                                    {
                                        FileError = true;
                                        result    = result + "Error on Uploading Files, try later";
                                    }

                                    if (ImgError || FileError || AGError)
                                    {
                                        return(Json(result, JsonRequestBehavior.AllowGet));
                                    }


                                    result = "Successfully Registered";
                                    return(Json(result, JsonRequestBehavior.AllowGet));
                                    //return RedirectToAction("Register");
                                }
                                else
                                {
                                    result = "There is already a game with this name"; return(Json(result, JsonRequestBehavior.AllowGet));
                                }
                            }
                            else
                            {
                                result = "Application Price is not acceptable"; return(Json(result, JsonRequestBehavior.AllowGet));
                            }
                        }
                        else
                        {
                            result = "The release date is not acceptable"; return(Json(result, JsonRequestBehavior.AllowGet));
                        }
                    }
                    else
                    {
                        result = "You are not a Developer"; return(Json(result, JsonRequestBehavior.AllowGet));
                    }
                }
                catch
                {
                    ViewBag.App = app;
                    result      = "An Error Occurred";
                    return(Json(result, JsonRequestBehavior.AllowGet));
                    //return RedirectToAction("Register");
                }
            }
            ViewBag.App   = app;
            ViewBag.Class = "alert alert-danger";
            result        = "An Error Occurred";
            return(Json(result, JsonRequestBehavior.AllowGet));
            //return View("Register");
        }