public IHttpActionResult DeleteProject([FromUri]long id) { var result = false; var dic = new Dictionary<string, string>(); var project = new Zs_Project(); project = bProject.Find(id); if (project == null) return NotFound(); //删除事历 result = bProject.Delete(project); //实体列表 var ganWuAttList = bProjectAtt.Entities.Where(f => f.ProjectID == project.ProjectID); //遍历删除本地资源 foreach (var item in ganWuAttList) sysFun.DeleteFile(item.AttType, item.AttUrl); //批量删除 if (ganWuAttList.Count() > 0) bProjectAtt.Delete(ganWuAttList); if (result) { dic.Add("result", "1"); return Ok(dic); } else { dic.Add("result", "0"); return Ok(dic); } }
public IHttpActionResult AddProject(AddProjectModel model) { var project = new Zs_Project(); var result = new ProjectViewModel(); //初始化实体 project = sysFun.InitialEntity<AddProjectModel, Zs_Project>(model, project); //添加事历 project = bProject.Add(project); //更新附件列表 result = UpdateAttList(project); if (project.ProjectID > 0) { return Ok(result); } else { return Ok("添加失败"); } }
/// <summary> /// 更新附件列表 /// </summary> /// <param name="project">事例信息</param> private ProjectViewModel UpdateAttList(Zs_Project project) { var result = new ProjectViewModel(); //实体列表 var projectAttList = bProjectAtt.Entities.Where(f => f.CreateDate < project.UpdateDate && f.ProjectID == 0); //遍历删除本地资源 foreach (var item in projectAttList) sysFun.DeleteFile(item.AttType, item.AttUrl); //批量删除 if (projectAttList.Count() > 0) bProjectAtt.Delete(projectAttList); //批量更新 bProjectAtt.Update(f => f.MID == project.MID, f => new Zs_ProjectAtt { ProjectID = project.ProjectID }); //实体列表 projectAttList = bProjectAtt.Entities.Where(f => f.MID == project.MID); result.Project = project; result.ProjectAtt = projectAttList.ToList(); return result; }
public IHttpActionResult UpdateProject(UpdateProjectModel model) { var project = new Zs_Project(); var result = new ProjectViewModel(); //初始化实体 project = bProject.Find(model.ProjectID); project = sysFun.InitialEntity<UpdateProjectModel, Zs_Project>(model, project); //更新事历 project = bProject.UpdateEntity(project); //更新附件列表 result = UpdateAttList(project); return Ok(result); }
public IHttpActionResult GetProjectById([FromUri]long id) { var project = new Zs_Project(); var projectAtt = new List<Zs_ProjectAtt>(); var result = new ProjectViewModel(); project = bProject.Find(id); projectAtt = bProjectAtt.Entities.Where(f => f.ProjectID == project.ProjectID).ToList(); result.Project = project; result.ProjectAtt = projectAtt; return Ok(result); }
public ActionResult ProjectCreate(ProjectCreate model) { if (!ModelState.IsValid) return View(model); var item = new Zs_Project(); item = sysFun.InitialEntity<ProjectCreate, Zs_Project>(model, item); item.UpdateDate = DateTime.Now; item.FinishedDate = DateTime.Now; item = bProject.Add(item); if (item.ProjectID > 0) return RedirectToAction("ProjectList"); return View(model); }