public IActionResult Index() { var qs = Request.QueryString; if (qs.IsNotNull() && qs.Value.IsNotNullOrEmpty() && qs.Value.Length > 3) { var value = qs.Value; if (value.Contains("&")) { value = value.Substring(0, value.IndexOf("&")); } var lang = Language.Greek; var _id = value.ToLower().Replace("?id=", "").Trim(); if (_id.StartsWith("g", StringComparison.CurrentCultureIgnoreCase)) { _id = _id.Substring(1); } if (_id.StartsWith("h", StringComparison.CurrentCultureIgnoreCase)) { _id = _id.Substring(1); lang = Language.Hebrew; } var id = _id.ToInt(); var strongCode = new XPQuery <StrongCode>(new UnitOfWork()).Where(x => x.Code == id && x.Lang == lang).FirstOrDefault(); if (strongCode.IsNotNull()) { return(View(strongCode)); } } return(View()); }
private void lblStrong_Click(object sender, EventArgs e) { if (Word.StrongCode.IsNotNull() && StrongClick.IsNotNull()) { StrongClick(this, Word.StrongCode); } else { var strongCode = XtraInputBox.Show("Insert Strong's code:", "Strong Codes", ""); if (strongCode.IsNotNullOrEmpty()) { var sc = new XPQuery <StrongCode>(Word.Session).Where(x => x.Code == strongCode.ToInt() && x.Lang == Language.Greek).FirstOrDefault(); if (sc.IsNotNull()) { Word.StrongCode = sc; (Word.Session as UnitOfWork).CommitChanges(); lblStrong.DataBindings.Add("Text", Word.StrongCode, "Code"); lblStrong.BackColor = Color.Transparent; AddStrongToolTip(Word.StrongCode); } } } }
public string GetVerseTranslation(Session session, int numberOfBook, int numberOfChapter, int verseStart, int verseEnd = 0, string translationName = "NPI") { if (verseEnd == 0) { var index = $"{translationName}.{numberOfBook}.{numberOfChapter}.{verseStart}"; var verse = new XPQuery <Verse>(session).Where(x => x.Index == index).FirstOrDefault(); if (verse.IsNotNull()) { var verseText = verse.GetTranslationText(); if (verseText.IsNotNullOrWhiteSpace()) { return(verseText); } else { return(GetOtherVerseTranslation(session, numberOfBook, numberOfChapter, verseStart)); } } else { return(GetOtherVerseTranslation(session, numberOfBook, numberOfChapter, verseStart)); } } else { var predicate = PredicateBuilder.New <Verse>(); for (int i = verseStart; i < verseEnd + 1; i++) { var index = $"{translationName}.{numberOfBook}.{numberOfChapter}.{i}"; predicate = predicate.Or(x => x.Index == index); } var verses = new XPQuery <Verse>(session).Where(predicate); if (verses.Count() > 0) { if (verses.First().GetTranslationText().IsNotNullOrWhiteSpace()) { var versesText = String.Empty; foreach (var item in verses) { versesText += item.GetTranslationText() + " "; } return(versesText.Trim()); } else { return(GetOtherVersesTranslation(session, numberOfBook, numberOfChapter, verseStart, verseEnd)); } } else { return(GetOtherVersesTranslation(session, numberOfBook, numberOfChapter, verseStart, verseEnd)); } } }
private string GetShortUrl(UnitOfWork uow) { var id = Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 5); var result = new XPQuery <UrlShort>(uow).Where(x => x.ShortUrl == id).FirstOrDefault(); if (result.IsNotNull()) { return(GetShortUrl(uow)); } return(id); }
private void txtIndex_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { var text = txtIndex.EditValue.ToString(); var verse = new XPQuery <Verse>(Uow).Where(x => x.Index == text).FirstOrDefault(); if (verse.IsNotNull()) { var verseNumber = verse.NumberOfVerse; if (VerseControl.Verse.IsNotNull() && VerseControl.IsModified()) { if (XtraMessageBox.Show("Do you want to save your changes before opening a new verse?", "Save", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { VerseControl.Save(); } } VerseControl.LoadData(verse, Translation.BookType == TheBookType.Bible); btnExportChapterToPDF.Enabled = btnExportChapterToWord.Enabled = btnExportBookToDocx.Enabled = btnExportBookToPdf.Enabled = btnNextVerse.Enabled = btnAutoTranslateChapter.Enabled = true; var allVerses = txtVerse.Properties.DataSource as List <int>; if (allVerses.IsNotNull() && allVerses.Count > 0 && verseNumber == allVerses.Last()) { btnNextVerse.Enabled = false; } btnPreviousVerse.Enabled = verseNumber > 1; var book = verse.ParentChapter.ParentBook.BaseBook; this.Text = $"{book.BookTitle} {verse.ParentChapter.NumberOfChapter}:{verseNumber}"; btnOblubienicaEu.Visibility = book.NumberOfBook >= 470 ? DevExpress.XtraBars.BarItemVisibility.Always : DevExpress.XtraBars.BarItemVisibility.Never; btnLogosSeptuagint.Visibility = book.NumberOfBook < 470 ? DevExpress.XtraBars.BarItemVisibility.Always : DevExpress.XtraBars.BarItemVisibility.Never; var bookInfo = (txtBooks.Properties.DataSource as List <BookBaseInfo>).Where(x => x.NumberOfBook == book.NumberOfBook).FirstOrDefault(); txtBooks.EditValue = bookInfo; Application.DoEvents(); editBook_EditValueChanged(this, new DevExpress.XtraEditors.Controls.ChangingEventArgs(null, bookInfo)); Application.DoEvents(); txtChapter.EditValue = verse.ParentChapter.NumberOfChapter; Application.DoEvents(); editChapter_EditValueChanged(this, new DevExpress.XtraEditors.Controls.ChangingEventArgs(null, verse.ParentChapter.NumberOfChapter)); Application.DoEvents(); txtVerse.EditValue = verse.NumberOfVerse; } } }
private void gridView_DoubleClick(object sender, EventArgs e) { var record = gridView.GetFocusedRow() as ViewRecord; if (record.IsNotNull()) { var article = new XPQuery <Article>(Uow).Where(x => x.Oid == record["Id"].ToInt()).FirstOrDefault(); if (article.IsNotNull()) { var frm = new ArticleEditorForm(article); frm.IconOptions.SvgImage = btnAddArticle.ImageOptions.SvgImage; frm.MdiParent = this.MdiParent; frm.Show(); } } }
private void btnDeleteArticle_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { var record = gridView.GetFocusedRow() as ViewRecord; if (record.IsNotNull()) { var article = new XPQuery <Article>(Uow).Where(x => x.Oid == record["Id"].ToInt()).FirstOrDefault(); if (article.IsNotNull()) { if (XtraMessageBox.Show("Are you sure delete selected article?", "Delete", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.Yes) { article.Delete(); LoadData(); } } } }
public void OnAuthorization(AuthorizationFilterContext context) { if (!context.HttpContext.User.Identity.IsAuthenticated) { if (context.IsNotNull() && context.RouteData.IsNotNull() && context.RouteData.Values.IsNotNull() && context.RouteData.Values.Count > 2) { var translationName = context.RouteData.Values["translationName"].ToString(); if (translationName.IsNotNull()) { var translation = new XPQuery <Translation>(new UnitOfWork()).Where(x => x.Name.Replace("'", "").Replace("+", "") == translationName && !x.OpenAccess).FirstOrDefault(); if (translation.IsNotNull()) { context.Result = new RedirectResult("/Account/Index?ReturnUrl=" + context.HttpContext.Request.Path.Value); } } } } }
private async Task <Stream> GetImage(string queryString) { var paramsTable = queryString.Split(','); if (paramsTable.Length > 0) { var articleId = paramsTable[0].ToInt(); if (articleId > 0) { var uow = new UnitOfWork(); var article = new XPQuery <Article>(uow).Where(x => x.Oid == articleId).FirstOrDefault(); if (article.IsNotNull()) { return(new MemoryStream(article.AuthorPicture)); } } } return(default);
private void lblStrong_DoubleClick(object sender, EventArgs e) { if (Word.StrongCode.IsNotNull()) { var strongCode = XtraInputBox.Show("Insert Strong's code:", "Strong Codes", lblStrong.Text); if (strongCode.IsNotNullOrEmpty()) { var sc = new XPQuery <StrongCode>(Word.Session).Where(x => x.Code == strongCode.ToInt() && x.Lang == Language.Greek).FirstOrDefault(); if (sc.IsNotNull()) { Word.StrongCode = sc; (Word.Session as UnitOfWork).CommitChanges(); lblStrong.Text = sc.Code.ToString(); lblStrong.BackColor = Color.Transparent; } } } }
private void editVerse_EditValueChanged(object sender, EventArgs e) { var arg = e as DevExpress.XtraEditors.Controls.ChangingEventArgs; if (arg.IsNotNull()) { var verseNumber = arg.NewValue.ToInt(); if (VerseControl.Verse.IsNotNull() && VerseControl.IsModified()) { if (XtraMessageBox.Show("Do you want to save your changes before opening a new verse?", "Save", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { VerseControl.Save(); } } Application.DoEvents(); var book = txtBooks.EditValue as BookBaseInfo; var chapterNumber = txtChapter.EditValue.ToInt(); var verse = new XPQuery <Verse>(Uow).Where(x => x.NumberOfVerse == verseNumber && x.ParentChapter.NumberOfChapter == chapterNumber && x.ParentChapter.ParentBook.NumberOfBook == book.NumberOfBook && x.ParentChapter.ParentBook.ParentTranslation.Name == NAME).FirstOrDefault(); if (verse.IsNotNull()) { VerseControl.LoadData(verse, Translation.BookType == TheBookType.Bible); btnExportChapterToPDF.Enabled = btnExportChapterToWord.Enabled = btnExportBookToDocx.Enabled = btnExportBookToPdf.Enabled = btnNextVerse.Enabled = btnAutoTranslateChapter.Enabled = btnAutoTranslateVerse.Enabled = true; var allVerses = txtVerse.Properties.DataSource as List <int>; if (allVerses.IsNotNull() && allVerses.Count > 0 && verseNumber == allVerses.Last()) { btnNextVerse.Enabled = false; } btnPreviousVerse.Enabled = verseNumber > 1; this.Text = $"{book.BookTitle} {chapterNumber}:{verseNumber}"; btnOblubienicaEu.Visibility = book.NumberOfBook >= 470 ? DevExpress.XtraBars.BarItemVisibility.Always : DevExpress.XtraBars.BarItemVisibility.Never; btnLogosSeptuagint.Visibility = book.NumberOfBook < 470 ? DevExpress.XtraBars.BarItemVisibility.Always : DevExpress.XtraBars.BarItemVisibility.Never; txtIndex.EditValue = verse.Index; // $"{Translation.Name.Replace("'", "").Replace("+", "")}.{book.NumberOfBook}.{chapterNumber}.{verseNumber}"; } } }
public IActionResult Index() { var qs = Request.QueryString; if (qs.IsNotNull() && qs.Value.IsNotNullOrEmpty() && qs.Value.Length > 3) { var value = qs.Value; if (value.Contains("&")) { value = value.Substring(0, value.IndexOf("&")); } var id = value.ToLower().Replace("?id=", "").Trim().ToInt(); var song = new XPQuery <Song>(new UnitOfWork()).Where(x => x.Number == id).FirstOrDefault(); if (song.IsNotNull()) { return(View(song)); } } return(View()); }
public IActionResult Index() { var qs = Request.QueryString; if (qs.IsNotNull() && qs.Value.IsNotNullOrEmpty() && qs.Value.Length > 3) { var value = qs.Value; if (value.Contains("&")) { value = value.Substring(0, value.IndexOf("&")); } var id = value.Replace("?id=", "").Trim(); var grammarCode = new XPQuery <GrammarCode>(new UnitOfWork()).Where(x => x.GrammarCodeVariant1 == id).FirstOrDefault(); if (grammarCode.IsNotNull()) { return(View(grammarCode)); } } return(View()); }
private void txtBaseBook_EditValueChanged(object sender, EventArgs e) { if (txtNumberOfBook.Text.ToInt() == 0) { var baseBookItem = txtBaseBook.EditValue as IbeBaseBookItem; var uow = Object.Session as UnitOfWork; var baseBook = new XPQuery <BookBase>(uow).Where(x => x.Oid == baseBookItem.Id).FirstOrDefault(); if (baseBook.IsNotNull()) { txtNumberOfBook.Text = baseBook.NumberOfBook.ToString(); txtBookColor.Text = baseBook.Color; txtAuthorName.Text = baseBook.AuthorName; txtBookName.Text = baseBook.BookName; txtBookShortcut.Text = baseBook.BookShortcut; txtBookTitle.Text = baseBook.BookTitle; txtPreface.Text = baseBook.Preface; txtSubject.Text = baseBook.Subject; txtTimeOfWriting.Text = baseBook.TimeOfWriting; txtPlaceWhereBookWasWritten.Text = baseBook.PlaceWhereBookWasWritten; } } }
public IActionResult Index() { var qs = Request.QueryString; if (qs.IsNotNull() && qs.Value.IsNotNullOrEmpty() && qs.Value.Length > 3) { var value = qs.Value; if (value.Contains("&")) { value = value.Substring(0, value.IndexOf("&")); } var id = value.ToLower().Replace("?id=", "").Trim().ToInt(); var article = new XPQuery <Article>(new UnitOfWork()).Where(x => x.Oid == id).FirstOrDefault(); if (article.IsNotNull()) { return(View(new ArticleControllerModel() { Article = article })); } } return(View()); }
public IActionResult Index(string translationName, string book = null, string chapter = null, string verse = null) { var uow = new UnitOfWork(); // adresy skrótowe if (!String.IsNullOrEmpty(translationName) && book.IsNull() && translationName.Length == 5) { var _url = new XPQuery <UrlShort>(uow).Where(x => x.ShortUrl == translationName).FirstOrDefault(); if (_url.IsNotNull()) { return(Redirect(_url.Url)); } } if (!String.IsNullOrEmpty(translationName)) { var books = new XPQuery <BookBase>(uow).ToList(); // wyświetlamy listę ksiąg z tego przekładu if (String.IsNullOrEmpty(book)) { var translation = new XPQuery <Translation>(uow).Where(x => x.Name.Replace("'", "").Replace("+", "").ToLower() == translationName.ToLower()).FirstOrDefault(); if (translation != null) { return(View(new TranslationControllerModel(translation, books: books))); } } else { var translation = new XPQuery <Translation>(uow).Where(x => x.Name.Replace("'", "").Replace("+", "").ToLower() == translationName.ToLower()).FirstOrDefault(); if (translation != null) { var result = new TranslationControllerModel(translation, book, chapter, verse, books); var view = new XPView(uow, typeof(Translation)) { CriteriaString = $"[Books][[NumberOfBook] = '{book}'] AND [Hidden] = 0" }; view.Properties.Add(new ViewProperty("Name", SortDirection.None, "[Name]", false, true)); view.Properties.Add(new ViewProperty("Description", SortDirection.None, "[Description]", false, true)); view.Properties.Add(new ViewProperty("Type", SortDirection.None, "[Type]", false, true)); view.Properties.Add(new ViewProperty("Catholic", SortDirection.None, "[Catolic]", false, true)); view.Properties.Add(new ViewProperty("Recommended", SortDirection.None, "[Recommended]", false, true)); view.Properties.Add(new ViewProperty("OpenAccess", SortDirection.None, "[OpenAccess]", false, true)); foreach (ViewRecord item in view) { result.Translations.Add(new TranslationInfo() { Name = item["Name"].ToString(), Description = item["Description"].ToString(), Type = (TranslationType)item["Type"], Catholic = (bool)item["Catholic"], Recommended = (bool)item["Recommended"], PasswordRequired = !((bool)item["OpenAccess"]) }); } return(View(result)); } } } return(View()); }
private void editVerse_EditValueChanged(object sender, EventArgs e) { var arg = e as DevExpress.XtraEditors.Controls.ChangingEventArgs; if (arg.IsNotNull()) { var verseNumber = arg.NewValue.ToInt(); //var currentControl = this.Controls.OfType<Control>().Where(x => x is VerseEditorControl).FirstOrDefault() as VerseEditorControl; //if (currentControl.IsNotNull()) { // if (currentControl.IsModified()) { // if (XtraMessageBox.Show("Do you want to save your changes before opening a new verse?", "Save", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { // currentControl.Save(); // } // } // this.Controls.Remove(currentControl); // currentControl.Dispose(); // currentControl = null; //} if (VerseControl.Verse.IsNotNull() && VerseControl.IsModified()) { if (XtraMessageBox.Show("Do you want to save your changes before opening a new verse?", "Save", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { VerseControl.Save(); } VerseControl.Clear(); } else { VerseControl.Clear(); } Application.DoEvents(); var book = txtBook.EditValue as BookBaseInfo; var chapterNumber = txtChapter.EditValue.ToInt(); var verse = new XPQuery <Verse>(Uow).Where(x => x.NumberOfVerse == verseNumber && x.ParentChapter.NumberOfChapter == chapterNumber && x.ParentChapter.ParentBook.NumberOfBook == book.NumberOfBook && x.ParentChapter.ParentBook.ParentTranslation.Name == NAME).FirstOrDefault(); if (verse.IsNotNull()) { //var control = new VerseEditorControl(verse, Translation.BookType == TheBookType.Bible) { // Dock = DockStyle.Fill //}; //this.Controls.Add(control); //control.LoadData(); VerseControl.LoadData(verse, Translation.BookType == TheBookType.Bible); btnExportChapterToPDF.Enabled = btnExportChapterToWord.Enabled = btnExportBookToDocx.Enabled = btnExportBookToPdf.Enabled = btnNextVerse.Enabled = true; var allVerses = editVerse.DataSource as List <int>; if (allVerses.IsNotNull() && allVerses.Count > 0 && verseNumber == allVerses.Last()) { btnNextVerse.Enabled = false; } btnPreviousVerse.Enabled = verseNumber > 1; this.Text = $"{book.BookTitle} {chapterNumber}:{verseNumber}"; btnOblubienicaEu.Visibility = book.NumberOfBook >= 470 ? DevExpress.XtraBars.BarItemVisibility.Always : DevExpress.XtraBars.BarItemVisibility.Never; btnLogosSeptuagint.Visibility = book.NumberOfBook < 470 ? DevExpress.XtraBars.BarItemVisibility.Always : DevExpress.XtraBars.BarItemVisibility.Never; } } }