コード例 #1
0
 public ActionResult Create(About pNewAbout)
 {
     try
     {
         HttpPostedFileBase file = HttpContext.Request.Files["pImage"];
         string a = "/Image/" + file.FileName;
         string b = Server.MapPath(a);
         file.SaveAs(b);
         var Image = new Image();
         Image.Image1 = a;
         return RedirectToAction("Index");
     }
     catch
     {
         return View();
     }
 }
コード例 #2
0
 public ActionResult Delete(int id, About pNewAbout)
 {
     try
     {
         // TODO: Add delete logic here
         var check = new AboutModel().Delete(id);
         if(check==true)
         {
             return RedirectToAction("Index");
         }
         else
         {
             return View(pNewAbout);
         }
     }
     catch
     {
         return View(pNewAbout);
     }
 }
コード例 #3
0
 public ActionResult Create(AboutView pNewAboutView)
 {
     About pNewAbout = new About();
     try
     {
         pNewAbout.Name = pNewAboutView.Name;
         pNewAbout.Descritp = pNewAboutView.Descritp;
         pNewAbout.Content = pNewAboutView.Content;
         pNewAbout.OrderDisplay = pNewAboutView.OrderDisplay;
         pNewAbout.Image = pNewAboutView.Image;
         pNewAbout.IsActive = pNewAboutView.IsActive;
         if(pNewAboutView.LangId=="Tiếng Việt")
         {
             pNewAbout.LangId = 0;
         }
         else
         {
             pNewAbout.LangId = 1;
         }
         pNewAbout.CreatedBy = account.Id;
         pNewAbout.CreatedDate = DateTime.Now;
         pNewAbout.EditBy = account.Id;
         pNewAbout.EditDate = DateTime.Now;
         var check = new AboutModel().Create(pNewAbout);
         if(check==true)
         {
             return RedirectToAction("Index");
         }
         else
         {
             return View(pNewAboutView);
         }
     }
     catch
     {
         return View(pNewAboutView);
     }
 }