public ActionResult Save(ProjectSituation situation) { if (string.IsNullOrEmpty(situation.Content)) { return(ErrorJsonResult("工作情况不能为空!")); } if (situation.ID > 0) { if (!Core.ProjectSituationManager.Edit(situation)) { return(ErrorJsonResult("编辑工作情况失败!")); } Core.ProjectRecordManager.Save(new ProjectRecord { Content = string.Format("{0}编辑工作情况", Identity.Name), ProjectId = situation.ProjectId, UserId = situation.UserId }); } else { var id = Core.ProjectSituationManager.Add(situation); if (id <= 0) { return(ErrorJsonResult("录入工作情况失败!")); } var recordId = Core.ProjectRecordManager.Save(new ProjectRecord { Content = string.Format("{0}录入工作情况", Identity.Name), ProjectId = situation.ProjectId, UserId = situation.UserId }); } return(SuccessJsonResult()); }
public bool Edit(ProjectSituation situation) { var model = DB.ProjectSituation.Find(situation.ID); if (model == null) { return(false); } DB.Entry(situation).CurrentValues.SetValues(situation); DB.SaveChanges(); return(true); }
public int Add(ProjectSituation situation) { DB.ProjectSituation.Add(situation); DB.SaveChanges(); return(situation.ID); }