public static void SaveDailyGospelReflection(int gospelId, string title, string content) { var service = new DailyGospelReflectionService(); if (service.UserHasReflection(Auth.user().Id, gospelId)) { var dailyGospelReflection = new DailyGospelReflection { UserId = Auth.user().Id, DailyGospelId = gospelId, Title = title, ReflectionContent = content }; if (string.IsNullOrWhiteSpace(title) && string.IsNullOrWhiteSpace(content)) { service.Delete(dailyGospelReflection); } else { service.Update(gospelId, dailyGospelReflection); } } else { var dailyGospelReflection = new DailyGospelReflection { UserId = Auth.user().Id, DailyGospelId = gospelId, Title = title, ReflectionContent = content }; service.Create(dailyGospelReflection); } }
public static List <DailyGospelReflection> GetGospelReflections() { var service = new DailyGospelReflectionService(); return(service.Get(Auth.user().Id)); }
public static DailyGospelReflection GetUserReflection(int gospelId) { var service = new DailyGospelReflectionService(); return(service.GetUserReflection(Auth.user().Id, gospelId)); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { Models.DailyGospel dailyGospel; var dailyGospelService = new DailyGospelService(); if (Page.RouteData.Values["gospel-id"] != null) { int id; if (int.TryParse(Page.RouteData.Values["gospel-id"].ToString(), out id)) { dailyGospel = dailyGospelService.Find(id); } else if (Page.RouteData.Values["gospel-id"].ToString().Length > 1) { dailyGospel = dailyGospelService.FindByDate(Convert.ToDateTime(Page.RouteData.Values["gospel-id"])); } else { dailyGospel = dailyGospelService.FindByDate(DateTime.UtcNow); } } else { var date = Request["date"] != null?Convert.ToDateTime(Request["date"]) : DateTime.UtcNow; dailyGospel = GetReading(date); } GospelID.Value = dailyGospel.Id.ToString(); SourceContent.InnerHtml = dailyGospel.Source; GospelDate.InnerHtml = dailyGospel.DateOfGospel.DayOfWeek + ", " + dailyGospel.DateOfGospel.ToString("MMMM dd, yyyy"); FRTitle.InnerHtml = dailyGospel.FirstReadingTitle; FRContent.InnerHtml = dailyGospel.FirstReadingContent; RPTitle.InnerHtml = dailyGospel.ResponsorialPsalmTitle; RPContent.InnerHtml = dailyGospel.ResponsorialPsalmContent; SRTitle.InnerHtml = dailyGospel.SecondReadingTitle; SRContent.InnerHtml = dailyGospel.SecondReadingContent; VBGTitle.InnerHtml = dailyGospel.VerseBeforeGospelTitle; VBGContent.InnerHtml = dailyGospel.VerseBeforeGospelContent; DGospelTitle.InnerHtml = dailyGospel.GospelTitle; DGospelContent.InnerHtml = dailyGospel.GospelContent; SecondReading.Attributes.Add("style", dailyGospel.SecondReadingTitle == "" ? "display:none" : "display:block"); SecondReading.Attributes.Add("style", dailyGospel.SecondReadingContent == "" ? "display:none" : "display:block"); VerseBeforeGospel.Attributes.Add("style", dailyGospel.VerseBeforeGospelTitle == "" ? "display:none" : "display:block"); VerseBeforeGospel.Attributes.Add("style", dailyGospel.VerseBeforeGospelContent == "" ? "display:none" : "display:block"); DateTime dateParam; dateParam = Request["date"] != null?Convert.ToDateTime(Request["date"]) : DateTime.UtcNow; var verse = GetVerse(dateParam); var quote = GetQuote(dateParam); //TextBox1.Text = DateTime.Now.ToString().Split(' ')[0] + " " + DateTime.Now.ToString().Split(' ')[1]; HttpUtility.HtmlEncode(BibleQuote.InnerHtml = verse.BibleVerseContent); HttpUtility.HtmlEncode(BibleVerse.InnerHtml = verse.ChapterTitle); RelQuote.InnerHtml = quote.Quote; Author.InnerHtml = quote.Author; var service = new DailyGospelReflectionService(); if (!service.UserHasReflection(Auth.user().Id, dailyGospel.Id)) { return; } var reflection = service.GetUserReflection(Auth.user().Id, dailyGospel.Id); GReflectTitle.Value = reflection.Title; GReflectContent.Value = reflection.ReflectionContent; } }