public static RefRangeViewModel ToRefRangeViewModel(this RefRange refRange) { if (Equals(refRange, null)) { return(null); } var refRangeViewModel = new RefRangeViewModel() { Id = refRange.Id, TestId = refRange.TestId, Age = refRange.Age, AgeRange = refRange.AgeRange, Gender = refRange.Gender, Notes = refRange.Notes, RefHigh = refRange.RefHigh, RefLow = refRange.RefLow, DayMonthYear = refRange.DayMonthYear }; if (!Equals(refRange.AgeEndRange, null)) { refRangeViewModel.AgeEndRange = refRange.AgeEndRange.Value; } return(refRangeViewModel); }
public async Task <IActionResult> PutRefRange([FromRoute] int id, [FromBody] RefRange refRange) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != refRange.Id) { return(BadRequest()); } refRange.DateModified = DateTime.Now; refRange.ModifiedBy = HttpContext.User.Identity.Name; _context.Entry(refRange).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RefRangeExists(id)) { return(NotFound()); } else { throw; } } return(Ok(refRange)); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Updates the Scripture reference for this footnote. /// </summary> /// ------------------------------------------------------------------------------------ private void UpdateFootnoteRef() { IScrBook owningBook = OwnerOfClass <IScrBook>(); if (owningBook == null) { throw new InvalidOperationException("Can not calculate footnote reference until footnote is inserted"); } if (ParaContainingOrcRA == null) { return; // Would be better to throw an exception, but will happen in tests } BCVRef startRef = new BCVRef(owningBook.CanonicalNum, 0, 0); BCVRef endRef = new BCVRef(owningBook.CanonicalNum, 0, 0); IScrSection owningSection = ParaContainingOrcRA.OwnerOfClass <IScrSection>(); if (owningSection != null && BCVRef.GetChapterFromBcv(owningSection.VerseRefStart) == BCVRef.GetChapterFromBcv(owningSection.VerseRefEnd)) { // Section only contains one chapter, so we know which chapter to use startRef.Chapter = endRef.Chapter = BCVRef.GetChapterFromBcv(owningSection.VerseRefStart); } IStText owningText = (IStText)ParaContainingOrcRA.Owner; for (int iPara = owningText.ParagraphsOS.IndexOf(ParaContainingOrcRA); iPara >= 0; iPara--) { IScrTxtPara para = (IScrTxtPara)owningText[iPara]; RefResult result = GetReference(owningBook, para, startRef, endRef); if (result == RefResult.ScannedAllFootnotes) { return; // no need to finish since full scan updated my reference } if (result == RefResult.Found) { break; } } if (owningSection != null) { if (startRef.Verse == 0) { startRef.Verse = endRef.Verse = new BCVRef(owningSection.VerseRefStart).Verse; } if (startRef.Chapter == 0) { startRef.Chapter = endRef.Chapter = new BCVRef(owningSection.VerseRefStart).Chapter; } } FootnoteRefInfo = new RefRange(startRef, endRef); }
public async Task <IActionResult> PostRefRange([FromBody] RefRange refRange) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } refRange.DateCreated = DateTime.Now; refRange.ModifiedBy = HttpContext.User.Identity.Name; refRange.Active = true; _context.RefRanges.Add(refRange); await _context.SaveChangesAsync(); return(CreatedAtAction("GetRefRange", new { id = refRange.Id }, refRange)); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Get a string representing the reference of the footnote (chapter:verse + trailing /// space) /// </summary> /// <param name="hvoWs">HVO of the writing system for which we are formatting this /// reference.</param> /// ------------------------------------------------------------------------------------ public string GetReference(int hvoWs) { if (!IgnoreDisplaySettings && !m_scr.GetDisplayFootnoteReference(ParaStyleId)) { return(string.Empty); } RefRange footnoteEntry = FootnoteRefInfo; // Don't display the reference if the reference is for an intro if (footnoteEntry.StartRef.Verse == 0 && footnoteEntry.EndRef.Verse == 0) { return(string.Empty); } return(m_scr.ChapterVerseBridgeAsString(footnoteEntry.StartRef, footnoteEntry.EndRef, hvoWs) + " "); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets the reference for this footnote. /// </summary> /// <param name="owningBook">The owning book.</param> /// <param name="para">The para to search for a Scripture reference (verse or chapter). /// </param> /// <param name="startRef">The starting reference for this footnote (updated in this /// method).</param> /// <param name="endRef">The ending reference for this footnote (updated in this /// method).</param> /// <returns></returns> /// ------------------------------------------------------------------------------------ private RefResult GetReference(IScrBook owningBook, IScrTxtPara para, BCVRef startRef, BCVRef endRef) { bool foundSelf = (para != ParaContainingOrcRA); IStFootnoteRepository footnoteRepo = Cache.ServiceLocator.GetInstance <IStFootnoteRepository>(); ITsString tssContents = para.Contents; for (int i = tssContents.RunCount - 1; i >= 0; i--) { string styleName = tssContents.get_StringProperty(i, (int)FwTextPropType.ktptNamedStyle); if (foundSelf && styleName == ScrStyleNames.VerseNumber && startRef.Verse == 0) { int nVerseStart, nVerseEnd; ScrReference.VerseToInt(tssContents.get_RunText(i), out nVerseStart, out nVerseEnd); startRef.Verse = nVerseStart; endRef.Verse = nVerseEnd; } else if (foundSelf && styleName == ScrStyleNames.ChapterNumber && startRef.Chapter == 0) { try { startRef.Chapter = endRef.Chapter = ScrReference.ChapterToInt(tssContents.get_RunText(i)); } catch (ArgumentException) { // ignore runs with invalid Chapter numbers } if (startRef.Verse == 0) { startRef.Verse = endRef.Verse = 1; } } else if (styleName == null) { IScrFootnote footnote = (IScrFootnote)footnoteRepo.GetFootnoteFromObjData(tssContents.get_StringProperty(i, (int)FwTextPropType.ktptObjData)); if (footnote != null) { if (footnote == this) { foundSelf = true; continue; } RefRange otherFootnoteLocation = ((ScrFootnote)footnote).FootnoteRefInfo_Internal; if (foundSelf && otherFootnoteLocation != RefRange.EMPTY) { // Found another footnote with a reference we can use if (startRef.Verse == 0) { startRef.Verse = otherFootnoteLocation.StartRef.Verse; endRef.Verse = otherFootnoteLocation.EndRef.Verse; } if (startRef.Chapter == 0) { startRef.Chapter = otherFootnoteLocation.StartRef.Chapter; endRef.Chapter = otherFootnoteLocation.EndRef.Chapter; } } else if (foundSelf) { // Previous footnote does not have a reference yet. We presume, for performance // reasons, that none of the previous footnotes have valid references yet, so // we set all the footnotes for the book. ((ScrBook)owningBook).RefreshFootnoteRefs(); return(RefResult.ScannedAllFootnotes); } } } if (startRef.Verse != 0 && endRef.Verse != 0 && startRef.Chapter != 0 && endRef.Chapter != 0) { return(RefResult.Found); } } return(RefResult.NotFound); }