Beispiel #1
0
        public static int DeleteReport(Report report)
        {
            using (DbEntities db = new DbEntities())
            {
                db.Attach(report);
                db.Reports.DeleteObject(report);
                db.ObjectStateManager.ChangeObjectState(report, System.Data.EntityState.Deleted);

                //remove transfer with this report
                var transfers = db.Transfers.Where(t => t.ReportFromId.Equals(report.Id) || t.ReportToId.Equals(report.Id)).ToList();
                transfers.ForEach(t => db.DeleteObject(t));

                return db.SaveChanges();
            }
        }
 /// <summary>
 /// Create a new Report object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="reportName">Initial value of the ReportName property.</param>
 /// <param name="header">Initial value of the Header property.</param>
 /// <param name="headerRow">Initial value of the HeaderRow property.</param>
 /// <param name="resultRow">Initial value of the ResultRow property.</param>
 public static Report CreateReport(global::System.Int32 id, global::System.String reportName, global::System.Boolean header, global::System.Int32 headerRow, global::System.Int32 resultRow)
 {
     Report report = new Report();
     report.Id = id;
     report.ReportName = reportName;
     report.Header = header;
     report.HeaderRow = headerRow;
     report.ResultRow = resultRow;
     return report;
 }
Beispiel #3
0
 public static int UpsertReport(Report report)
 {
     using (DbEntities db = new DbEntities())
     {
         if (report.EntityKey == null)
         {
             //new report so insert
             db.Reports.AddObject(report);
             //db.ObjectStateManager.ChangeObjectState(newReport, System.Data.EntityState.Added);
         }
         else
         {
             //update report
             db.Attach(report);
             db.ObjectStateManager.ChangeObjectState(report, System.Data.EntityState.Modified);
         }
         return db.SaveChanges();
     }
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Reports EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToReports(Report report)
 {
     base.AddObject("Reports", report);
 }
 public static void UpsertReport(Report report)
 {
     CRUD.UpsertReport(report);
 }
 public static void DeleteReport(Report report)
 {
     CRUD.DeleteReport(report);
 }
 public void UpsertReport(Report report)
 {
     Business.UpsertReport(report);
 }
 public void DeleteReport(Report report)
 {
     Business.DeleteReport(report);
 }