예제 #1
0
 public ActionResult HakkimizdaEkle(AddAboutInfoModel model, HttpPostedFileBase imagePath)
 {
     // var nick = Session["aktif"].ToString();
     if (model.About != null)
     {
         try
         {
             AboutPage about = db.aboutInfo.FirstOrDefault();
             if (about == null)
             {
                 AboutPage a = new AboutPage();
                 a.About  = model.About;
                 a.Header = model.Header;
                 if (imagePath != null)
                 {
                     if (System.IO.File.Exists(Server.MapPath(a.imagePath)))
                     {
                         System.IO.File.Delete(Server.MapPath(a.imagePath));
                     }
                     a.imagePath = ImageAddAbout(imagePath);
                 }
                 else
                 {
                     a.imagePath = null;
                 }
                 db.aboutInfo.Add(a);
             }
             else
             {
                 about.About = model.About;
                 if (imagePath != null)
                 {
                     if (System.IO.File.Exists(Server.MapPath(about.imagePath)))
                     {
                         System.IO.File.Delete(Server.MapPath(about.imagePath));
                     }
                     about.imagePath = ImageAddAbout(imagePath);
                 }
             }
             db.SaveChanges();
         }
         catch (Exception e)
         {
             ViewBag.ds = "Hata";
         }
         return(RedirectToAction("HakkimizdaEkle"));
     }
     return(View());
 }
예제 #2
0
        public ActionResult HakkimizdaEkle()
        {
            AboutPage about = db.aboutInfo.FirstOrDefault();

            if (about == null)
            {
                return(View());
            }
            else
            {
                AddAboutInfoModel model = new AddAboutInfoModel();
                model.Header    = about.Header;
                model.imagePath = about.imagePath;
                model.About     = about.About;
                return(View(model));
            }
        }