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