コード例 #1
0
ファイル: EnterController.cs プロジェクト: urbs44/WhiteGloss
        public ActionResult Edit(EnterPage page, HttpPostedFileBase file)
        {
            try
            {
                //EnterPage ep = db.EnterPage.First();
                // Verify that the user selected a file
                if (file != null && file.ContentLength > 0)
                {
                    // extract only the fielname
                    var fileName = Path.GetFileName(file.FileName);
                    // store the file inside ~/App_Data/uploads folder
                    string newFileName = DateTime.Now.ToFileTimeUtc().ToString() + "_" + fileName;
                    var path = Path.Combine(Server.MapPath("~/Content/uploads"), newFileName);
                    file.SaveAs(path);
                    page.Image = "/Content/uploads/" + newFileName;
                }
                db.Entry(page).State = EntityState.Modified;
                //ep.Text = page.Text;
                db.SaveChanges();

                return RedirectToAction("Index", "Admin");
            }
            catch
            {
                return View(db.EnterPage.First());
            }
        }
コード例 #2
0
ファイル: HomeController.cs プロジェクト: urbs44/WhiteGloss
        public ActionResult Index()
        {
            WgArtists data = new WgArtists();
            EnterPage model = new EnterPage();
            model = (from a in data.EnterPage select a).FirstOrDefault();

            return View(model);
        }
コード例 #3
0
ファイル: EnterController.cs プロジェクト: urbs44/WhiteGloss
        public ActionResult Create(EnterPage page, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                // Verify that the user selected a file
                if (file != null && file.ContentLength > 0)
                {
                    // extract only the fielname
                    var fileName = Path.GetFileName(file.FileName);
                    // store the file inside ~/App_Data/uploads folder
                    string newFileName = DateTime.Now.ToFileTimeUtc().ToString() + "_" + fileName;
                    var path = Path.Combine(Server.MapPath("~/Content/uploads"), newFileName);
                    file.SaveAs(path);
                    page.Image = "/Content/uploads/" + newFileName;
                }

                db.EnterPage.Add(page);
                db.SaveChanges();
                return RedirectToAction("Index", "Admin");
            }

            return View(page);
        }
コード例 #4
0
ファイル: EnterController.cs プロジェクト: urbs44/WhiteGloss
 //
 // GET: /Enter/Create
 public ActionResult Create()
 {
     EnterPage ep = new EnterPage();
     return View(ep);
 }