예제 #1
0
 public ActionResult NewsAndUpdated(tbl_NewsAndUpdatedss model, HttpPostedFileBase files)
 {
     try
     {
         if (model.pkid == 0)
         {
             tbl_NewsAndUpdated abc = new tbl_NewsAndUpdated();
             abc.Title        = model.Title;
             abc.Description  = model.Description;
             abc.status       = model.status;
             abc.ProfilePic   = model.ProfilePic;
             abc.Addate       = DateTime.Now;
             abc.lastModified = DateTime.Now;
             if (files != null)
             {
                 string path = System.Web.HttpContext.Current.Server.MapPath(model.ProfilePic);
                 if (System.IO.File.Exists(path))
                 {
                     System.IO.File.Delete(path);
                 }
                 WebFunction web = new WebFunction();
                 abc.ProfilePic = web.Storefile(files, 6);
             }
             _news.Add(abc);
         }
         else
         {
             int _id = Convert.ToInt32(model.pkid);
             tbl_NewsAndUpdated abc = _news.Get(_id);
             abc.Title        = model.Title;
             abc.status       = model.status;
             abc.Description  = model.Description;
             abc.ProfilePic   = model.ProfilePic;
             abc.lastModified = DateTime.Now;
             if (files != null)
             {
                 string path = System.Web.HttpContext.Current.Server.MapPath(model.ProfilePic);
                 if (System.IO.File.Exists(path))
                 {
                     System.IO.File.Delete(path);
                 }
                 WebFunction web = new WebFunction();
                 abc.ProfilePic = web.Storefile(files, 6);
             }
             _news.Update(abc);
         }
         return(RedirectToAction("NewsAndUpdated", "Administration"));
     }
     catch (Exception e)
     {
         Commonfunction.LogError(e, Server.MapPath("~/Log.txt"));
         ViewBag.Exception = e.Message;
         return(View());
     }
 }
예제 #2
0
        public ActionResult DeleteNews(int id)
        {
            try
            {
                WebFunction        web = new WebFunction();
                tbl_NewsAndUpdated abc = _news.Get(id);
                _tourim.Remove(id, false);

                return(RedirectToAction("NewsAndUpdated", "Administration"));
            }
            catch
            {
                return(RedirectToAction("NewsAndUpdated", "Administration"));
            }
        }
예제 #3
0
 public ActionResult NewsAndUpdated(string id)
 {
     if (!String.IsNullOrWhiteSpace(id))
     {
         int _id = Convert.ToInt32(id);
         tbl_NewsAndUpdated   model = _news.Get(_id);
         tbl_NewsAndUpdatedss abc   = new tbl_NewsAndUpdatedss();
         abc.pkid        = model.pkid;
         abc.Title       = model.Title;
         abc.status      = model.status;
         abc.Description = model.Description;
         abc.ProfilePic  = model.ProfilePic;
         return(View(abc));
     }
     return(View());
 }