Esempio n. 1
0
 public ActionResult Edit(FormCollection collection)
 {
     int NewsId = int.Parse(collection["NewsId"]);
     NewsDetail nd = new NewsDetail
     {
         NEW_TITLE = collection["NewsTitle"],
         NEW_CONTENT = collection["NewsContent"],
     };
     if (nm.Update(NewsId, nd))
     {
         return RedirectToAction("Index");
     }
     else
     {
         ViewData["Error"] = "Can not update news content";
         return View();
     }
 }
Esempio n. 2
0
 partial void DeleteNewsDetail(NewsDetail instance);
Esempio n. 3
0
 partial void UpdateNewsDetail(NewsDetail instance);
Esempio n. 4
0
 partial void InsertNewsDetail(NewsDetail instance);
Esempio n. 5
0
		private void detach_NewsDetails(NewsDetail entity)
		{
			this.SendPropertyChanging();
			entity.LoginDetail = null;
		}
Esempio n. 6
0
        public string PostNews(string Title, string Content, int OwnerId)
        {
            NewsDetail nd = new NewsDetail
            {
                NEW_MODIFY_TIME = DateTime.Today,
                USER_ID = OwnerId,
                NEW_TITLE = Title,
                NEW_CONTENT = Content,
            };

            db.NewsDetails.InsertOnSubmit(nd);
            try{
                db.SubmitChanges();
                return "OK";
            }catch(Exception ex){
                return ex.Message;
            }
        }
Esempio n. 7
0
 public bool Update(int NewsId, NewsDetail nd)
 {
     var update = from nsd in db.NewsDetails
                  where nsd.NEW_ID == NewsId
                  select nsd;
     if (update.Any())
     {
         update.Single().NEW_CONTENT = nd.NEW_CONTENT;
         update.Single().NEW_TITLE = nd.NEW_TITLE;
         try
         {
             db.SubmitChanges();
             return true;
         }
         catch (Exception ex) {
             return false;
         }
     }
     else {
         return false;
     }
 }