public JsonResult UpdateReport([FromBody] ReportObj reportObj) { var report = _context.Reports.FirstOrDefault(r => r.ID == reportObj.ReportID); if (report == null) { report = new Report(); _context.Reports.Add(report); _context.SaveChanges(); } report.Updated = DateTime.Now; Location location = new Location { ReportID = report.ID, Longitude = reportObj.Longitude, Latitude = reportObj.Latitude, DateTime = DateTime.Now }; _context.Locations.Add(location); _context.SaveChanges(); var result = new ReportResult(200, "Success", report.ID); return(Json(result)); }
public ReportObj GetReport(int monthnum, int yearid) { GoodSamaritanContext ctx = new GoodSamaritanContext(); ReportObj reportData = new ReportObj(); reportData.genderMale = (from c in ctx.Clients where c.Month == monthnum where c.FiscalYearId == yearid where c.Gender == "Male" select c).Count(); reportData.genderFemale = (from c in ctx.Clients where c.Month == monthnum where c.FiscalYearId == yearid where c.Gender == "Female" select c).Count(); reportData.genderTrans = (from c in ctx.Clients where c.Month == monthnum where c.FiscalYearId == yearid where c.Gender == "Trans" select c).Count(); reportData.age24_65 = (int)(from c in ctx.Clients where c.Month == monthnum where c.FiscalYearId == yearid where c.Age.Range == "Adult >24<65" select c).Count(); reportData.age18_25 = (from c in ctx.Clients where c.Month == monthnum where c.FiscalYearId == yearid where c.Age.Range == "Youth >18<25" select c).Count(); reportData.age12_19 = (from c in ctx.Clients where c.Month == monthnum where c.FiscalYearId == yearid where c.Age.Range == "Youth >12<19" select c).Count(); reportData.age13 = (from c in ctx.Clients where c.Month == monthnum where c.FiscalYearId == yearid where c.Age.Range == "Child <13" select c).Count(); reportData.age64 = (from c in ctx.Clients where c.Month == monthnum where c.FiscalYearId == yearid where c.Age.Range == "Senior >64" select c).Count(); reportData.statusOpen = (from c in ctx.Clients where c.Month == monthnum where c.FiscalYearId == yearid where c.StatusOfFile.Status == "Open" select c).Count(); reportData.statusClosed = (from c in ctx.Clients where c.Month == monthnum where c.FiscalYearId == yearid where c.StatusOfFile.Status == "Closed" select c).Count(); reportData.statusReopened = (from c in ctx.Clients where c.Month == monthnum where c.FiscalYearId == yearid where c.StatusOfFile.Status == "Reopened" select c).Count(); reportData.programCrisis = (from c in ctx.Clients where c.Month == monthnum where c.FiscalYearId == yearid where c.Program.Type == "Crisis" select c).Count(); reportData.programCourt = (from c in ctx.Clients where c.Month == monthnum where c.FiscalYearId == yearid where c.Program.Type == "Court" select c).Count(); reportData.programSMART = (from c in ctx.Clients where c.Month == monthnum where c.FiscalYearId == yearid where c.Program.Type == "SMART" select c).Count(); reportData.programDVU = (from c in ctx.Clients where c.Month == monthnum where c.FiscalYearId == yearid where c.Program.Type == "DVU" select c).Count(); reportData.programMCFD = (from c in ctx.Clients where c.Month == monthnum where c.FiscalYearId == yearid where c.Program.Type == "MCFD" select c).Count(); return(reportData); }