public void Delete_Id_Doesnt_Exist() { var attachmentManager = new AttachmentManager(100); bool delete = attachmentManager.Delete(); Assert.IsTrue(delete); }
public ActionResult DeleteAttachment(int id) { OperationResult OperationResult = new OperationResult(); OperationResult = attachmentManager.Delete(id); if (OperationResult.Success) { return(Json(new { ID = id })); } else { return(Json(new { ID = "", message = OperationResult.Message })); } }
protected void AttachmentDataList_ItemCommand(object source, DataListCommandEventArgs e) { String attchmentId = ((Label)e.Item.FindControl("lblAttchmentId")).Text; if (attchmentId != "") { long requestId = long.Parse(((Label)e.Item.FindControl("lblRequestId")).Text); long lAttachment = long.Parse(attchmentId); var attachmentManager = new AttachmentManager(); var attachment = new Attachment(); attachment = attachmentManager.GetQuery(p => p.AttachmentID == lAttachment).FirstOrDefault(); attachmentManager.Delete(attachment); SetAttachment(requestId); Response.Write("<script>alert(' فایل ضمیمه مورد نظر از درخواست مورد نظر حذف گردید')</script>"); } }
public virtual object SaveProcessAs(HttpContext context) { YZRequest request = new YZRequest(context); int folder = request.GetInt32("folder"); string fileid = request.GetString("fileid"); int filefolderid = request.GetInt32("filefolderid"); string processName = request.GetString("processName"); string ext = request.GetString("ext"); JObject jPost = request.GetPostData <JObject>(); JObject jProcess = (JObject)jPost["process"]; JObject jChart = (JObject)jPost["chart"]; if (jProcess["Property"] == null) { jProcess["Property"] = new JObject(); } jProcess["Property"]["CreateAt"] = DateTime.Now; jProcess["Property"]["Creator"] = YZAuthHelper.LoginUserAccount; jProcess["Property"]["LastChange"] = DateTime.Now; jProcess["Property"]["ChangeBy"] = YZAuthHelper.LoginUserAccount; string savePath = AttachmentInfo.FileIDToPath(fileid, AttachmentManager.AttachmentRootPath); System.IO.Directory.CreateDirectory(savePath.Substring(0, savePath.LastIndexOf(@"\"))); using (System.IO.StreamWriter ws = new System.IO.StreamWriter(savePath, false, System.Text.Encoding.UTF8)) ws.Write(jProcess.ToString()); AttachmentInfo attachment = new AttachmentInfo(); attachment.FileID = fileid; attachment.Name = processName; attachment.Ext = ext; attachment.Size = 101; attachment.LastUpdate = DateTime.Now; attachment.OwnerAccount = YZAuthHelper.LoginUserAccount; attachment.LParam1 = filefolderid; YZSoft.FileSystem.File file = new YZSoft.FileSystem.File(); file.FolderID = folder; file.FileID = fileid; file.AddBy = YZAuthHelper.LoginUserAccount; file.AddAt = DateTime.Now; file.Comments = ""; File bpafile = jProcess.ToObject <File>(); bpafile.FileID = fileid; bpafile.FileName = attachment.Name; using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider) { using (IDbConnection cn = provider.OpenConnection()) { AttachmentManager.Delete(provider, cn, attachment.FileID); AttachmentManager.Insert(provider, cn, attachment); file.OrderIndex = YZSoft.FileSystem.DirectoryManager.GetFileNextOrderIndex(provider, cn, folder); FileSystem.DirectoryManager.Insert(provider, cn, file); bpafile.UpdateSpritesIdentityAndLink(provider, cn); } } this.SaveChart(savePath, jChart); return(new { success = true, fileid = file.FileID }); }
public JsonResult AttachmentDel(int id) { var attachment = new AttachmentManager(id); return(Json(attachment.Delete())); }