public void DeleteMainRow() { if (SelectedMainRows != null) { var res = MessageBox.Show("Are You To Delete SelectedRecords From Database ?", "Delete", MessageBoxButton.OKCancel); if (res == MessageBoxResult.OK) { foreach (var row in SelectedMainRows) { var record = new TblAttachment(); record.InjectFrom(row); assistanceClient.DeleteAttachmentAsync(record, MainRowList.IndexOf(row)); } } } }
private int DeleteAttachment(TblAttachment row) { using (var context = new WorkFlowManagerDBEntities()) { var temp = context.TblAttachments.FirstOrDefault(ah => ah.Iserial == row.Iserial); if (temp != null) { context.DeleteObject(temp); } if (context.SaveChanges() > 0) { if (File.Exists(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath + temp.Path)) { File.Delete(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath + temp.Path); } } } return(row.Iserial); }