Example #1
0
 public ActionResult Addnotice(tbl_NoticeBoardMasterss model, HttpPostedFileBase image)
 {
     try
     {
         if (model.pkid == 0)
         {
             tbl_NoticeBoardMaster abc = new tbl_NoticeBoardMaster();
             if (image != null)
             {
                 WebFunction web = new WebFunction();
                 model.Image_Path = web.Storefile(image, 2);
             }
             abc.NoticeName        = model.NoticeName;
             abc.NoticeDescription = model.NoticeDescription;
             abc.Image_Path        = model.Image_Path;
             abc.AddedDate         = DateTime.Now;
             abc.RequiredDays      = model.RequiredDays;
             abc.Active            = model.Active;
             abc.LastModifiedDate  = DateTime.Now;
             _notice.Add(abc);
         }
         else
         {
             int _id = Convert.ToInt32(model.pkid);
             tbl_NoticeBoardMaster abc = _notice.Get(_id);
             if (image != null)
             {
                 string path = System.Web.HttpContext.Current.Server.MapPath(model.Image_Path);
                 if (System.IO.File.Exists(path))
                 {
                     System.IO.File.Delete(path);
                 }
                 WebFunction web = new WebFunction();
                 model.Image_Path = web.Storefile(image, 2);
             }
             abc.pkid              = model.pkid;
             abc.NoticeName        = model.NoticeName;
             abc.NoticeDescription = model.NoticeDescription;
             abc.Image_Path        = model.Image_Path;
             abc.AddedDate         = model.AddedDate;
             abc.RequiredDays      = model.RequiredDays;
             abc.Active            = model.Active;
             abc.LastModifiedDate  = DateTime.Now;
             _notice.Update(abc);
         }
         return(RedirectToAction("Addnotice", "Administration"));
     }
     catch (Exception e)
     {
         Commonfunction.LogError(e, Server.MapPath("~/Log.txt"));
         ViewBag.Exception = e.Message;
         return(View());
     }
 }
Example #2
0
 public ActionResult Addnotice(string id)
 {
     if (!String.IsNullOrWhiteSpace(id))
     {
         int _id = Convert.ToInt32(id);
         tbl_NoticeBoardMaster   model = _notice.Get(_id);
         tbl_NoticeBoardMasterss abc   = new tbl_NoticeBoardMasterss();
         abc.pkid              = model.pkid;
         abc.NoticeName        = model.NoticeName;
         abc.NoticeDescription = model.NoticeDescription;
         abc.Image_Path        = model.Image_Path;
         abc.AddedDate         = model.AddedDate;
         abc.RequiredDays      = model.RequiredDays;
         abc.Active            = model.Active;
         return(View(abc));
     }
     return(View());
 }