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