public IHttpActionResult DeleteProjectAtt([FromUri] string id) { long AttID = 0; var deleteResult = false; var ganWuAtt = new Zs_GanWuAtt(); var hashTable = new Hashtable(); var fileData = new List<FileDataInfo>(); var dic = new Dictionary<string, string>(); //附件编号 if (!long.TryParse(id, out AttID)) return BadRequest("附件编号格式不正确"); //查找当前附件 ganWuAtt = bGanWuAtt.Find(AttID); //检测是否存在 if (ganWuAtt == null) return NotFound(); //删除本地附件 sysFun.DeleteFile(ganWuAtt.AttType, ganWuAtt.AttUrl); //删除数据库附件 deleteResult = bGanWuAtt.Delete(ganWuAtt); if (deleteResult) { dic.Add("result", "1"); return Ok(dic); } else { dic.Add("result", "0"); return Ok(dic); } }
public async Task<IHttpActionResult> AddOrUpdateGanWuAtt() { var ganWuAtt = new Zs_GanWuAtt(); var hashTable = new Hashtable(); var fileData = new List<FileDataInfo>(); var formData = new Dictionary<string, string>(); //获取表单数据 hashTable = await sysFun.GetFormData(Request); formData = hashTable["FormData"] as Dictionary<string, string>; fileData = hashTable["FileData"] as List<FileDataInfo>; foreach (var item in fileData) { ganWuAtt = new Zs_GanWuAtt(); if (formData.ContainsKey("AttID")) { //查找当前附件 ganWuAtt = bGanWuAtt.Find(long.Parse(formData["AttID"])); //检测是否存在 if (ganWuAtt == null) return NotFound(); //删除本地附件 sysFun.DeleteFile(ganWuAtt.AttType, ganWuAtt.AttUrl); ganWuAtt.AttTitle = item.AttTitle; ganWuAtt.AttType = item.AttType; ganWuAtt.AttUrl = item.AttUrl; ganWuAtt.AttInfo = item.AttInfo; ganWuAtt = bGanWuAtt.UpdateEntity(ganWuAtt); } else if (formData.ContainsKey("MID")) { ganWuAtt.MID = long.Parse(formData["MID"]); ganWuAtt.GWID = 0; ganWuAtt.AttTitle = item.AttTitle; ganWuAtt.AttType = item.AttType; ganWuAtt.AttUrl = item.AttUrl; ganWuAtt.AttInfo = item.AttInfo; ganWuAtt = bGanWuAtt.Add(ganWuAtt); } } return Ok(ganWuAtt); }