public IHttpActionResult PostNews_Info(News_Info news_Info) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.News_Info.Add(news_Info); try { db.SaveChanges(); } catch (DbUpdateException) { if (News_InfoExists(news_Info.InfoID)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = news_Info.InfoID }, news_Info)); }
public IHttpActionResult PutNews_Info(Guid id, News_Info news_Info) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != news_Info.InfoID) { return(BadRequest()); } db.Entry(news_Info).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!News_InfoExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetNews_Info(Guid id) { News_Info news_Info = db.News_Info.Find(id); if (news_Info == null) { return(NotFound()); } return(Ok(news_Info)); }
public IHttpActionResult DeleteNews_Info(Guid id) { News_Info news_Info = db.News_Info.Find(id); if (news_Info == null) { return(NotFound()); } db.News_Info.Remove(news_Info); db.SaveChanges(); return(Ok(news_Info)); }
public JsonHelp Save(string type, string id, string title, string content, int ReadNum, string userid, string name) { JsonHelp json = new JsonHelp() { Status = "n", Msg = "保存失败" }; int intid = 0; int.TryParse(id, out intid); switch (type) { case "1": //编辑新闻 News_Info entity1 = DB.News_Info.FindEntity(intid); if (entity1 != null) { entity1.Title = title; entity1.Comment = content; entity1.ReadNum = ReadNum; entity1.LastEditTime = DateTime.Now; if (Update(entity1)) { json.Status = "y"; json.Msg = "保存成功"; json.ReUrl = "/Admin_Information/News/Index"; //添加操作日志 DB.SysLogs.setAdminLog("Edit", "更新标题为[" + entity1.Title + "]的新闻信息"); } } break; case "2": //添加新闻 News_Info entity2 = new News_Info(); entity2.Title = title; entity2.Comment = content; entity2.ReadNum = ReadNum; entity2.LastEditTime = DateTime.Now; entity2.CreateEmpId = userid; entity2.CreateEmpName = name; if (Insert(entity2)) { json.Status = "y"; json.Msg = "保存成功"; json.ReUrl = "/Admin_Information/News/Index"; //添加操作日志 DB.SysLogs.setAdminLog("Add", "新增标题为[" + entity2.Title + "]的新闻信息"); } break; case "3": //公司简介 Article_Info entity3 = DB.Article_Info.FindEntity(intid); if (entity3 != null) { entity3.Title = title; entity3.Comment = content; entity3.ReadNum = ReadNum; entity3.LastEditTime = DateTime.Now; if (DB.Article_Info.Update(entity3)) { json.Status = "y"; json.Msg = "保存成功"; //添加操作日志 DB.SysLogs.setAdminLog("Edit", "更新标题为[" + entity3.Title + "]的公司简介"); } } break; case "4": //公司账户 Article_Info entity4 = DB.Article_Info.FindEntity(intid); if (entity4 != null) { entity4.Title = title; entity4.Comment = content; entity4.ReadNum = ReadNum; entity4.LastEditTime = DateTime.Now; if (DB.Article_Info.Update(entity4)) { json.Status = "y"; json.Msg = "保存成功"; //添加操作日志 DB.SysLogs.setAdminLog("Edit", "更新标题为[" + entity4.Title + "]的公司简介"); } } break; case "5": //销售方案 Article_Info entity5 = DB.Article_Info.FindEntity(intid); if (entity5 != null) { entity5.Title = title; entity5.Comment = content; entity5.ReadNum = ReadNum; entity5.LastEditTime = DateTime.Now; if (DB.Article_Info.Update(entity5)) { json.Status = "y"; json.Msg = "保存成功"; //添加操作日志 DB.SysLogs.setAdminLog("Edit", "更新标题为[" + entity5.Title + "]的公司简介"); } } break; default: break; } return(json); }