private bool Remove(PaymentVendor data, SqlConnection oConn) { int totalFiles = 0; string msg = ""; IList <Attached> files = repAtt.GetList(false, data.PayVendorCreatedBy, ref totalFiles, ref msg, data.PayVendorId); if (files != null) { foreach (var file in files) { File.Delete(file.AttachFilePath); } } string sql = "DELETE FROM PaymentVendors " + " WHERE (PayVendorId = @id)"; SqlCommand cmd = new SqlCommand(sql, oConn); cmd.Parameters.Add("@id", SqlDbType.Int).Value = data.PayVendorId; int number = Convert.ToInt32(cmd.ExecuteNonQuery()); if (number > 0) { return(true); } return(false); }
public object GetAll() { var nvc = Request.RequestUri.ParseQueryString(); bool dirty = false; string strDirty = nvc["Dirty"]; bool.TryParse(strDirty, out dirty); string currentUser = nvc["CurrentUser"]; int PayVendorId = Convert.ToInt32(nvc["PayVendorId"]); int totalRecords = 0; try { object json; string msgError = ""; IList <Attached> lista; lista = repository.GetList(dirty, currentUser, ref totalRecords, ref msgError, PayVendorId); json = new { total = totalRecords, data = lista, success = true }; return(json); } catch (Exception ex) { LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message); object error = new { message = ex.Message }; object json = new { message = ex.Message, success = false }; return(json); } }