public ActionResult Delete(int id, news_post news) { try { newsObj.commitDelete(id); return(RedirectToAction("Index")); } catch { return(View()); } }
public static string Create_News_Post(news_post _news_post) { try { _news_post.news_id = Guid.NewGuid().ToString(); _news_post.post_on = DateTime.Now; newsDataContext.news_posts.InsertOnSubmit(_news_post); newsDataContext.SubmitChanges(); return _news_post.news_id; } catch (Exception ex) { return string.Format("Fail : {0}",ex.Message); } }
public ActionResult Update(int id, news_post newsUpd) { if (ModelState.IsValid) { try { newsObj.commitUpdate(id, newsUpd.date, newsUpd.heading, newsUpd.details); return(RedirectToAction("Details/" + id)); } catch { return(View()); } } return(View()); }
public ActionResult Insert(news_post post) { if (ModelState.IsValid) { try { newsObj.commitInsert(post); return(RedirectToAction("Index")); } catch { return(View()); } } else { return(View()); } }
protected void lbtn_post_Click(object sender, EventArgs e) { news_post _news_post = new news_post(); _news_post.subject = tb_title.Text; _news_post.body = tb_post.Text; _news_post.news_source_id = ddl_source.SelectedValue; _news_post.news_type_id = ddl_news_type.SelectedValue; _news_post.img_url = tb_image_url.Text; String result= News_Helper.Create_News_Post(_news_post); if (result.Contains("Fail")) { ShowMessageBox(result); } else { Reset_Form(); ShowMessageBox("Post Successfully!"); } }
partial void Deletenews_post(news_post instance);
partial void Updatenews_post(news_post instance);
partial void Insertnews_post(news_post instance);