public ActionResult Update(tblNews model) { _db.Entry(model).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); ViewBag.CateId = new SelectList(_db.tblDictionary.Where(p => p.CategoryId == 6).ToList(), "Id", "Title", model.CateId); return(RedirectToAction("Index")); }
public ResultDTO postNews([FromBody] NewsCreateDTO model) { try { tblNews newNews = new tblNews() { DatePost = model.DatePost, Description = model.Description, LinkImage = model.LinkImage, Title = model.Title }; _context.News.Add(newNews); _context.SaveChanges(); return(new ResultDTO { Status = 200, Message = "OK" }); } catch (Exception e) { return(new ResultDTO { Status = 500, Message = e.Message }); } }
public override void DeleteNews(int id) { var context = new MyLifeEntities(); var obj = new tblNews {Id = id}; context.DeleteObject(obj); context.SaveChanges(); }
public void Update(tblNews news) { var found = repos.Find(news.Id); found = news; repos.Update(found); }
public override void UpdateNews(Web.News.News news) { var context = new MyLifeEntities(); var obj = new tblNews {Id = news.Id}; context.AttachTo("tblNews", obj); news.CopyToObject(obj); context.SaveChanges(); }
public override int InsertNews(Web.News.News news) { var context = new MyLifeEntities(); var obj = new tblNews(); news.CopyToObject(obj); context.AddTotblNews(obj); context.SaveChanges(); return obj.Id; }
private static Web.News.News Convert(tblNews obj) { if (obj == null) { return null; } var news = new Web.News.News(obj.Id, obj.CreatedDate, obj.CreatedBy, obj.ModifiedDate, obj.ModifiedBy); news.CopyFromObject(obj); return news; }
public ActionResult Create(tblNews model) { if (Request["btnSave"] != null) { model.CreateDate = DateTime.Now; _db.tblNews.Add(model); _db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CateId = new SelectList(_db.tblDictionary.Where(p => p.CategoryId == 6).ToList(), "Id", "Title", model.CateId); return(View()); }
public ActionResult Create(tblNews model) { if (Request["btnSave"] != null) { model.CreateDate = DateTime.Now; model.CateId = 23; _db.tblNews.Add(model); _db.SaveChanges(); return(RedirectToAction("Index")); } return(View()); }
public IActionResult GetNews(int PKNews) { try { tblNews _tblNews = _ItblNewsRepository.GetSingle(x => x.PKNews == PKNews); return(Ok(_tblNews)); } catch (Exception ex) { log.Fatal("GetNews:", ex); return(BadRequest(ex.ToString())); } }
public IHttpActionResult InsertNewsItem(NewsItem newsItem) { PenOCDataContext db = new PenOCDataContext(); tblNews newsItemRecord = new tblNews { dteDate = newsItem.date, strTitle = newsItem.title, strNews = newsItem.news }; db.tblNews.InsertOnSubmit(newsItemRecord); db.SubmitChanges(); newsItem.id = newsItemRecord.idNews; return Ok(newsItem); }
public ActionResult Update(tblNews model) { _db.Entry(model).State = System.Data.Entity.EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }
public void AddNews(tblNews news) { repos.Create(news); }
/// <summary> /// Create a new tblNews object. /// </summary> /// <param name="id">Initial value of Id.</param> /// <param name="createdDate">Initial value of CreatedDate.</param> /// <param name="createdBy">Initial value of CreatedBy.</param> /// <param name="modifiedDate">Initial value of ModifiedDate.</param> /// <param name="modifiedBy">Initial value of ModifiedBy.</param> /// <param name="title">Initial value of Title.</param> /// <param name="slug">Initial value of Slug.</param> /// <param name="content">Initial value of Content.</param> public static tblNews CreatetblNews(int id, global::System.DateTime createdDate, string createdBy, global::System.DateTime modifiedDate, string modifiedBy, string title, string slug, string content) { tblNews tblNews = new tblNews(); tblNews.Id = id; tblNews.CreatedDate = createdDate; tblNews.CreatedBy = createdBy; tblNews.ModifiedDate = modifiedDate; tblNews.ModifiedBy = modifiedBy; tblNews.Title = title; tblNews.Slug = slug; tblNews.Content = content; return tblNews; }
/// <summary> /// There are no comments for tblNews in the schema. /// </summary> public void AddTotblNews(tblNews tblNews) { base.AddObject("tblNews", tblNews); }