コード例 #1
0
        }//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
コード例 #2
0
 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);
         }
     }
 }
コード例 #3
0
        } // Post/Create new Report

        /// <summary>
        /// Gets the specific Report , will return null if not found
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public static FieldReportDoc GetFieldReport(int ID)
        {
            using (FieldReportDBEntities DB = new FieldReportDBEntities())
            {
                var item = DB.FieldReports.SingleOrDefault(One => One.Id == ID);
                if (item != null)
                {
                    var R = new FieldReportDoc()
                    {
                        Id    = item.Id,
                        Date  = new SimpleDate(item.ReportDate),
                        Text  = Utilities.RenderTextTohtml(item.Content),
                        Title = item.Title
                    };
                    return(R);
                }
                else
                {
                    return(null);
                }
            }
        } // Get One
コード例 #4
0
        } // Delete Report

        public static FieldReportDoc GetReportForEdit(int ID)
        {
            using (FieldReportDBEntities DB = new FieldReportDBEntities())
            {
                var item = DB.FieldReports.SingleOrDefault(One => One.Id == ID);
                if (item != null)
                {
                    var R = new FieldReportDoc()
                    {
                        Id    = item.Id,
                        Date  = new SimpleDate(item.ReportDate),
                        Text  = Utilities.BackToOldNativeString(item.Content), // In here we render the text back to native string
                        Title = item.Title
                    };
                    return(R);
                }
                else
                {
                    return(null);
                }
            }
        }
コード例 #5
0
        public IHttpActionResult Write([FromBody] FieldReportDoc text)
        {
            int id = DbFunctions.Report(text);

            return(Ok(id));
        } // Post Report
コード例 #6
0
        public IHttpActionResult SaveChangesForReport([FromBody] FieldReportDoc UpdatedReport)//Updates the relevent report with new values
        {
            int id = DbFunctions.UpdateReport(UpdatedReport);

            return(Ok(id));
        }