}//Get list of Report Id /// <summary> /// Write a new Report /// </summary> /// <param name="documentary"></param> public static int Report(FieldReportDoc documentary) { using (FieldReportDBEntities DB = new FieldReportDBEntities()) { DB.FieldReports.Add(documentary.ConvertToRow()); DB.SaveChanges(); var id = ByNewestId(); return(id); } } // Post/Create new Report
public static bool DeleteReportFromDB(int ID) { using (FieldReportDBEntities DB = new FieldReportDBEntities()) { var row = DB.FieldReports.SingleOrDefault(One => One.Id == ID); if (row != null) { DB.FieldReports.Remove(row); DB.SaveChanges(); return(true); } else { return(false); } } } // Delete Report
public static int UpdateReport(FieldReportDoc Updated) { using (FieldReportDBEntities DB = new FieldReportDBEntities()) { var row = DB.FieldReports.SingleOrDefault(rw => rw.Id == Updated.Id); if (row != null) { row.ReportDate = Updated.Date.ToDateTime; // Date row.Title = Updated.Title; // Title row.Content = Utilities.StoreInSQL(Updated.Text); // Text/Content DB.SaveChanges(); return(Updated.Id.Value); } else { return(-1); } } }