예제 #1
0
        protected void Save_Clicked(object sender, EventArgs e)
        {
            var heading       = Heading.Text;
            var myTranslation = HttpUtility.HtmlDecode(MyTranslation.Text);
            var footnote      = HttpUtility.HtmlDecode(Footnote.Text);
            var newPara       = NewPara.Checked;

            var surah = int.Parse(Request["surah"] ?? "1");
            var ayah  = int.Parse(Request["ayah"] ?? "1");

            using (var quran = new QuranContext())
            {
                var existingTranslation = quran.MyTranslations.FirstOrDefault(t => t.SurahNo == surah && t.AyahNo == ayah);
                if (existingTranslation == null)
                {
                    var newTranslation = new MyTranslation
                    {
                        AyahNo           = ayah,
                        SurahNo          = surah,
                        Heading          = heading,
                        Translation      = myTranslation,
                        Footnote         = footnote,
                        NewParaAfterThis = newPara,
                        CreatedDate      = DateTime.Now,
                        LastUpdateDate   = DateTime.Now
                    };

                    quran.MyTranslations.Add(newTranslation);
                    quran.SaveChanges();
                }
                else
                {
                    existingTranslation.NewParaAfterThis = newPara;
                    existingTranslation.SurahNo          = surah;
                    existingTranslation.AyahNo           = ayah;
                    existingTranslation.Heading          = heading;
                    existingTranslation.Translation      = myTranslation;
                    existingTranslation.Footnote         = footnote;
                    existingTranslation.LastUpdateDate   = DateTime.Now;

                    quran.SaveChanges();
                }
            }
        }
예제 #2
0
        protected void Save_Clicked(object sender, EventArgs e)
        {
            var heading = Heading.Text;
            var myTranslation = HttpUtility.HtmlDecode(MyTranslation.Text);
            var footnote = HttpUtility.HtmlDecode(Footnote.Text);
            var newPara = NewPara.Checked;

            var surah = int.Parse(Request["surah"] ?? "1");
            var ayah = int.Parse(Request["ayah"] ?? "1");

            using (var quran = new QuranContext())
            {
                var existingTranslation = quran.MyTranslations.FirstOrDefault(t => t.SurahNo == surah && t.AyahNo == ayah);
                if (existingTranslation == null)
                {
                    var newTranslation = new MyTranslation
                    {
                        AyahNo = ayah,
                        SurahNo = surah,
                        Heading = heading,
                        Translation = myTranslation,
                        Footnote = footnote,
                        NewParaAfterThis = newPara,
                        CreatedDate = DateTime.Now,
                        LastUpdateDate = DateTime.Now
                    };

                    quran.MyTranslations.Add(newTranslation);
                    quran.SaveChanges();
                }
                else
                {
                    existingTranslation.NewParaAfterThis = newPara;
                    existingTranslation.SurahNo = surah;
                    existingTranslation.AyahNo = ayah;
                    existingTranslation.Heading = heading;
                    existingTranslation.Translation = myTranslation;
                    existingTranslation.Footnote = footnote;
                    existingTranslation.LastUpdateDate = DateTime.Now;

                    quran.SaveChanges();
                }
            }
        }