public string GetSmpData(ReportReason reportReason) { // Check if we have some location data if (_location != null) { // We do so build the SMP string and return it var smp = new SMP { Reason = reportReason, Latitude = Convert.ToDecimal(_location.Coordinates.Latitude), Longitude = Convert.ToDecimal(_location.Coordinates.Longitude), Speed = Convert.ToInt16(_location.Coordinates.Speed) > (short)2 ? Convert.ToInt16(_location.Coordinates.Speed) : (short)0, Quality = Convert.ToInt32(_location.Coordinates.Accuracy), LastFixDateTime = _location.Timestamp.DateTime, Heading = Convert.ToInt16(_location.Coordinates.Heading), ReportDateTime = DateTime.UtcNow }; return(smp.ToString()); } else { // We don't so build what we can and return it var smp = new SMP { Reason = reportReason, ReportDateTime = DateTime.UtcNow }; return(smp.ToString()); } }
public async Task <IActionResult> Create([Bind("ID,WardID,PresidingID,ConductingID,Date,OpeningHymnID,SacramentHymnID,IntermediateHymnID,ClosingHymnID,InvocationID,BenedictionID")] SMP sMP) { if (ModelState.IsValid) { _context.Add(sMP); await _context.SaveChangesAsync(); //return RedirectToAction(nameof(Index)); } ViewData["BenedictionID"] = new SelectList(_context.Member, "ID", "ID", sMP.BenedictionID); ViewData["ClosingHymnID"] = new SelectList(_context.Hymn, "ID", "ID", sMP.ClosingHymnID); ViewData["ConductingID"] = new SelectList(_context.Member, "ID", "ID", sMP.ConductingID); ViewData["IntermediateHymnID"] = new SelectList(_context.Hymn, "ID", "ID", sMP.IntermediateHymnID); ViewData["InvocationID"] = new SelectList(_context.Member, "ID", "ID", sMP.InvocationID); ViewData["OpeningHymnID"] = new SelectList(_context.Hymn, "ID", "ID", sMP.OpeningHymnID); ViewData["PresidingID"] = new SelectList(_context.Member, "ID", "ID", sMP.PresidingID); ViewData["SacramentHymnID"] = new SelectList(_context.Hymn, "ID", "ID", sMP.SacramentHymnID); ViewData["WardID"] = new SelectList(_context.Ward, "ID", "ID", sMP.WardID); return(RedirectToAction("Create", "Speakers", new { SMPID = sMP.ID })); }
public async Task <IActionResult> Edit(int id, [Bind("ID,WardID,PresidingID,ConductingID,Date,OpeningHymnID,SacramentHymnID,IntermediateHymnID,ClosingHymnID,InvocationID,BenedictionID")] SMP sMP) { if (id != sMP.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(sMP); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SMPExists(sMP.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["BenedictionID"] = new SelectList(_context.Member, "ID", "ID", sMP.BenedictionID); ViewData["ClosingHymnID"] = new SelectList(_context.Hymn, "ID", "ID", sMP.ClosingHymnID); ViewData["ConductingID"] = new SelectList(_context.Member, "ID", "ID", sMP.ConductingID); ViewData["IntermediateHymnID"] = new SelectList(_context.Hymn, "ID", "ID", sMP.IntermediateHymnID); ViewData["InvocationID"] = new SelectList(_context.Member, "ID", "ID", sMP.InvocationID); ViewData["OpeningHymnID"] = new SelectList(_context.Hymn, "ID", "ID", sMP.OpeningHymnID); ViewData["PresidingID"] = new SelectList(_context.Member, "ID", "ID", sMP.PresidingID); ViewData["SacramentHymnID"] = new SelectList(_context.Hymn, "ID", "ID", sMP.SacramentHymnID); ViewData["WardID"] = new SelectList(_context.Ward, "ID", "ID", sMP.WardID); return(View(sMP)); }