public string GetAppName(int id) { ApplicationDAO dao = new ApplicationDAO(); Application a = dao.SearchById(id); return(a.Name); }
public ActionResult Index() { try { ApplicationDAO appdao = new ApplicationDAO(); UpdateNotesDAO updao = new UpdateNotesDAO(); CartDAO cdao = new CartDAO(); IList <Application> apps = appdao.ListLast10(); IList <Application> bapps = appdao.ListTop10(); IList <UpdateNotes> updates = updao.GetLast3(); IList <Application> appsinupdates = new List <Application>(); foreach (var u in updates) { if (u.Value.Length > 144) { u.Value = u.Value.Substring(0, 144); } appsinupdates.Add(appdao.SearchById(u.ApplicationId)); } if (Session["Id"] != null) { ViewBag.Cart = cdao.SearchCartUser(int.Parse(Session["Id"].ToString())); } ViewBag.Updates = updates; ViewBag.AppsinUpdates = appsinupdates; ViewBag.BApps = bapps; ViewBag.NApps = apps; return(View()); } catch { return(RedirectToAction("Index", "Home")); } }
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")); } }
public ActionResult Wishlist() { try { if (Session["Id"] != null) { WishlistDAO wdao = new WishlistDAO(); ApplicationDAO adao = new ApplicationDAO(); CartDAO cdao = new CartDAO(); int UserId = int.Parse(Session["Id"].ToString()); IList <Wishlist> wishs = wdao.GetUserList(UserId); IList <Application> apps = new List <Application>(); foreach (var w in wishs) { apps.Add(adao.SearchById(w.ApplicationId)); } ViewBag.Cart = cdao.SearchCartUser(int.Parse(Session["Id"].ToString())); ViewBag.WishApps = wishs; ViewBag.Apps = apps; return(View()); } return(RedirectToAction("Index", "Home")); } catch { return(RedirectToAction("Index", "Home")); } }
public ActionResult ApproveApp(int id) { try { if (Session["ModId"] != null) { UserDAO udao = new UserDAO(); User u = udao.SearchById(int.Parse(Session["Id"].ToString())); ImageDAO idao = new ImageDAO(); ApplicationDAO dao = new ApplicationDAO(); TypeAppDAO tdao = new TypeAppDAO(); GenreDAO gdao = new GenreDAO(); PegiDAO pdao = new PegiDAO(); ApplicationGenreDAO agdao = new ApplicationGenreDAO(); ViewBag.Types = tdao.List(); ViewBag.Pegis = pdao.List(); ViewBag.AppGens = agdao.ListByApplication(id); ViewBag.Genres = gdao.List(); ViewBag.User = u; ViewBag.App = dao.SearchById(id); ViewBag.Img = idao.SearchAppImages(id); return(View()); } return(RedirectToAction("Index", "Home")); } catch { return(RedirectToAction("Index", "Home")); } }
public string GetAppImage(int id) { ApplicationDAO dao = new ApplicationDAO(); Application a = dao.SearchById(id); return(a.ImageUrl); }
public PartialViewResult _GameValue(int id) { ApplicationDAO adao = new ApplicationDAO(); ViewBag.App = adao.SearchById(id); return(PartialView()); }
public ActionResult Register(Review review) { try { ReviewDAO dao = new ReviewDAO(); UserDAO udao = new UserDAO(); review.Date = DateTime.Now; User u = udao.SearchById(int.Parse(Session["Id"].ToString())); review.UserId = u.Id; Review rev = dao.SearchByUserApp(review.UserId, review.ApplicationId); if (rev != null) { dao.Remove(rev); } dao.Add(review); IList <Review> revs = dao.SearchByAppId(review.ApplicationId); double totalrate = 0; foreach (var r in revs) { totalrate += r.Value; } totalrate = Math.Round(totalrate / revs.Count); ApplicationDAO appdao = new ApplicationDAO(); Application a = appdao.SearchById(review.ApplicationId); a.Value = int.Parse(totalrate.ToString()); appdao.Update(); return(RedirectToAction("Product", "Application", new { id = review.ApplicationId })); } catch { return(RedirectToAction("Index", "Home")); } }
public ActionResult SearchByGenre(int id) { try { ApplicationDAO dao = new ApplicationDAO(); ApplicationGenreDAO agdao = new ApplicationGenreDAO(); IList <ApplicationGenre> agens = agdao.ListByGenre(id); IList <Application> apps = new List <Application>(); CartDAO cdao = new CartDAO(); if (Session["Id"] != null) { ViewBag.Cart = cdao.SearchCartUser(int.Parse(Session["Id"].ToString())); } foreach (var ag in agens) { apps.Add(dao.SearchById(ag.ApplicationId)); } ViewBag.Apps = apps; return(View("Search")); } catch { return(RedirectToAction("Index", "Home")); } }
public ActionResult SearchMyndie() { try { ApplicationDAO dao = new ApplicationDAO(); Application a = dao.SearchById(39); return(RedirectToAction("Product", "Application", new { id = a.Id })); } catch { return(RedirectToAction("Index", "Home")); } }
public ActionResult EditPhoto(int id, int PhotoId, HttpPostedFileBase img) { try { ApplicationDAO dao = new ApplicationDAO(); Application a = dao.SearchById(id); if (Session["ModId"] != null || int.Parse(Session["DevId"].ToString()) == a.DeveloperId) { ImageDAO idao = new ImageDAO(); Image i = idao.SearchById(PhotoId); bool b = false; if (a.ImageUrl == i.Url) { b = true; } //Delete Photo in Server string p = i.Url; p = p.Replace("../../..", ".."); string fullPath = Request.MapPath(p); idao.Remove(i); if (System.IO.File.Exists(fullPath)) { System.IO.File.Delete(fullPath); } //Upload string filePath = Guid.NewGuid() + Path.GetExtension(img.FileName); img.SaveAs(Path.Combine(Server.MapPath("~/media/app"), filePath)); Image im = new Image(); im.Url = "../../../media/app/" + filePath; im.UserId = int.Parse(Session["Id"].ToString()); im.ApplicationId = a.Id; idao.Add(im); if (b) { a.ImageUrl = im.Url; dao.Update(); } return(RedirectToAction("EditApp", "Application", new { id = a.Id })); } return(RedirectToAction("Index", "Home")); } catch { return(RedirectToAction("Index", "Home")); } }
public ActionResult Remove(int id) { try { ApplicationDAO dao = new ApplicationDAO(); ImageDAO idao = new ImageDAO(); Application a = dao.SearchById(id); if (Session["ModId"] != null || int.Parse(Session["DevId"].ToString()) == a.DeveloperId) { try { IList <Image> imgs = idao.SearchAppImages(a.Id); foreach (var i in imgs) { string p = i.Url; p = p.Replace("../../..", "../.."); string fullPath = Request.MapPath(p); idao.Remove(i); if (System.IO.File.Exists(fullPath)) { System.IO.File.Delete(fullPath); } } } catch { } try { string pa = a.Archive; pa = pa.Replace("../../..", "../.."); string fullPathArch = Request.MapPath(pa); if (System.IO.File.Exists(fullPathArch)) { System.IO.File.Delete(fullPathArch); } } catch { } dao.Remove(a); return(RedirectToAction("Summary", "Developer")); } return(RedirectToAction("Index", "Home")); } catch { return(RedirectToAction("Index", "Home")); } }
public ActionResult TurntoMain(int id, int AppId) { try { ApplicationDAO dao = new ApplicationDAO(); Application a = dao.SearchById(AppId); if (Session["ModId"] != null || int.Parse(Session["DevId"].ToString()) == a.DeveloperId) { ImageDAO idao = new ImageDAO(); Image i = idao.SearchById(id); a.ImageUrl = i.Url; dao.Update(); return(RedirectToAction("EditApp", "Application", new { id = a.Id })); } return(RedirectToAction("Index", "Home")); } catch { return(RedirectToAction("Index", "Home")); } }
public ActionResult UpdateApp(int id) { try { ApplicationDAO dao = new ApplicationDAO(); UserDAO udao = new UserDAO(); Application app = dao.SearchById(id); if (int.Parse(Session["DevId"].ToString()) == app.DeveloperId) { ViewBag.User = udao.SearchById(int.Parse(Session["Id"].ToString())); ViewBag.App = app; return(View()); } return(RedirectToAction("Index", "Home")); } catch { return(RedirectToAction("Index", "Home")); } }
public ActionResult EditApp(int id) { try { ApplicationDAO dao = new ApplicationDAO(); Application App = dao.SearchById(id); UserDAO udao = new UserDAO(); TypeAppDAO tdao = new TypeAppDAO(); PegiDAO pdao = new PegiDAO(); GenreDAO gdao = new GenreDAO(); ApplicationGenreDAO agdao = new ApplicationGenreDAO(); if (Session["ModId"] != null || App.DeveloperId == int.Parse(Session["DevId"].ToString())) { ViewBag.User = udao.SearchById(int.Parse(Session["Id"].ToString())); ImageDAO idao = new ImageDAO(); ViewBag.Imgs = idao.SearchAppImages(App.Id); ViewBag.App = App; ViewBag.Types = tdao.List(); ViewBag.Pegis = pdao.List(); IList <Genre> genres = gdao.ListId(); IList <ApplicationGenre> agens = agdao.ListByApplication(id); foreach (var ag in agens) { foreach (var g in genres) { if (ag.GenreId == g.Id) { g.IsChecked = true; } } } ViewBag.Genres = genres; return(View()); } return(RedirectToAction("Index", "Home")); } catch { return(RedirectToAction("Index", "Home")); } }
public ActionResult UpdateAppData(UpdateNotes update, HttpPostedFileBase file) { try { ApplicationDAO dao = new ApplicationDAO(); UpdateNotesDAO updao = new UpdateNotesDAO(); Application app = dao.SearchById(update.ApplicationId); if (int.Parse(Session["DevId"].ToString()) == app.DeveloperId && update.Value != null) { updao.Add(update); //Delete File in Server string p = app.Archive; p = p.Replace("../../..", ".."); string fullPath = Request.MapPath(p); if (System.IO.File.Exists(fullPath)) { System.IO.File.Delete(fullPath); } //File string filePath2 = Guid.NewGuid() + Path.GetExtension(file.FileName); if (!Directory.Exists(Server.MapPath("~/apps/appfiles/" + app.Id))) { Directory.CreateDirectory(Server.MapPath("~/apps/appfiles/" + app.Id)); } file.SaveAs(Path.Combine(Server.MapPath("~/apps/appfiles/" + app.Id), filePath2)); app.Archive = "../../../apps/appfiles/" + app.Id + "/" + filePath2; dao.Update(); // return(RedirectToAction("Summary", "Developer")); } return(RedirectToAction("Index", "Home")); } catch { return(RedirectToAction("Index", "Home")); } }
public ActionResult AddtoCart(int appid) { try { CartDAO dao = new CartDAO(); if (!dao.CheckCart(appid, int.Parse(Session["Id"].ToString()))) { ApplicationDAO appdao = new ApplicationDAO(); Cart c = new Cart(); c.UserId = int.Parse(Session["Id"].ToString()); c.ApplicationId = appid; Application app = appdao.SearchById(appid); c.Price = app.Price; dao.Add(c); } return(RedirectToAction("Cart", "Cart")); } catch { return(RedirectToAction("Index", "Home")); } }
public ActionResult NewPhoto(int id, HttpPostedFileBase img) { try { ApplicationDAO dao = new ApplicationDAO(); Application a = dao.SearchById(id); if (Session["ModId"] != null || int.Parse(Session["DevId"].ToString()) == a.DeveloperId) { ImageDAO idao = new ImageDAO(); string filePath = Guid.NewGuid() + Path.GetExtension(img.FileName); img.SaveAs(Path.Combine(Server.MapPath("~/media/app"), filePath)); Image im = new Image(); im.Url = "../../../media/app/" + filePath; im.UserId = int.Parse(Session["Id"].ToString()); im.ApplicationId = a.Id; idao.Add(im); return(RedirectToAction("EditApp", "Application", new { id = a.Id })); } return(RedirectToAction("Index", "Home")); } catch { return(RedirectToAction("Index", "Home")); } }
public ActionResult UpdateGenres(IList <Genre> genres, int appId) { try { ApplicationDAO dao = new ApplicationDAO(); Application app = dao.SearchById(appId); if (Session["ModId"] != null || app.DeveloperId == int.Parse(Session["DevId"].ToString())) { ApplicationGenreDAO agdao = new ApplicationGenreDAO(); IList <ApplicationGenre> ags = agdao.ListByApplication(appId); foreach (var g in genres) { foreach (var ag in ags) { if (ag.GenreId == g.Id) { if (!g.IsChecked) { agdao.Remove(ag); } } } if (g.IsChecked == true) { ApplicationGenre ag = new ApplicationGenre(); ag.ApplicationId = appId; ag.GenreId = g.Id; agdao.Add(ag); } } return(RedirectToAction("EditApp", "Application", new { id = appId })); } return(RedirectToAction("Index", "Home")); } catch { return(RedirectToAction("Index", "Home")); } }
public ActionResult Approve(int id) { try { if (Session["ModId"] != null) { ApplicationDAO dao = new ApplicationDAO(); Application a = dao.SearchById(id); a.Approved = 1; dao.Update(); return(RedirectToAction("ProfileView", "Moderator")); } else { return(RedirectToAction("Index", "Home")); } } catch { return(RedirectToAction("Index", "Home")); } }
public ActionResult UpdateInfo(Application app) { try { if (Session["ModId"] != null || app.DeveloperId == int.Parse(Session["DevId"].ToString())) { ApplicationDAO dao = new ApplicationDAO(); Application a = dao.SearchById(app.Id); a.Name = app.Name; a.Desc = app.Desc; a.Price = app.Price; a.TypeAppId = app.TypeAppId; a.PegiId = app.PegiId; dao.Update(); return(RedirectToAction("EditApp", "Application", new { id = app.Id })); } return(RedirectToAction("Index", "Home")); } catch { return(RedirectToAction("Index", "Home")); } }