Exemplo n.º 1
0
 public static string getCategoryName(int?categoryID)
 {
     using (dbDataContext db = new dbDataContext())
     {
         return(db.Categories.Where(n => n.Id == categoryID).Select(n => n.Name).SingleOrDefault());
     }
 }
Exemplo n.º 2
0
 private void loadCards(int?category, int?postID)
 {
     using (dbDataContext db = new dbDataContext())
     {
         var    cardsInfo  = db.Posts.Where(n => n.Category == category && n.Id != postID).OrderByDescending(n => n.Id).Take(6);
         string infoString = "";
         foreach (var c in cardsInfo)
         {
             infoString += "<div class='card'><span class='catSpan'>" + globalMethods.getCategoryName(c.Category) + "</span><img src='getImage.ashx?PostID=" + c.Id + "&Size=thumbnail' alt='" +
                           c.HeadLine + "'><div class='cardHeadline'>" + c.HeadLine + " <a href='News.aspx?ID=" + globalMethods.EncodeID(c.Id) + "' target='_blank' style='font-size:10px'>Read more..</a></div></div>";
         }
         RelatedNews.InnerHtml = infoString;
     }
 }
Exemplo n.º 3
0
        private void FindResult(string searchTerm)
        {
            var posts = new List <Post>();

            using (dbDataContext db = new dbDataContext())
            {
                var splitedSearch = searchTerm.Split(' ');
                foreach (var s in splitedSearch)
                {
                    posts.AddRange(db.Posts.Where(n => n.HeadLine.Contains(s)).ToList());
                }
                loadResults(posts);
            }
        }
Exemplo n.º 4
0
 private void loadHoroscope()
 {
     using (dbDataContext db = new dbDataContext())
     {
         var horosocpe = db.Zodiacs.Select(n => new
         {
             n.Id,
             zodiac = n.Zodiac_English + "(" + n.Zodiac_Odia + ")",
             hs     = db.Horoscopes.Where(m => m.Zodiac_ID == n.Id && m.Date == DateTime.Now.Date).Select(o => o.Horoscope_English).FirstOrDefault()
         }).ToList();
         string empty = "";
         foreach (var h in horosocpe)
         {
             empty += "<li class='zodiac' onclick='window.open('Zodiac.aspx?h=" + h.zodiac + "')'><p>" + h.zodiac + "</p><span class='tooltipText'>" + h.hs + "</span></li>";
         }
         rashifal.InnerHtml = empty;
     }
 }
Exemplo n.º 5
0
 public void ProcessRequest(HttpContext context)
 {
     using (dbDataContext db = new dbDataContext())
     {
         var    postID = Convert.ToInt32(context.Request.QueryString["PostID"]);
         string Size   = context.Request.QueryString["Size"].ToString().ToLower();
         var    post   = db.Posts.Where(n => n.Id == postID).SingleOrDefault();
         if (post != null)
         {
             var img      = BinaryToImage(post.Image.ToArray());
             var imgArray = GetBytesFromImage(generateImage(img, Size));
             context.Response.ContentType = "image/jpg";
             context.Response.OutputStream.Write(imgArray, 0, imgArray.Length);
             context.Response.Flush();
             context.Response.End();
         }
     }
 }
Exemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                setDateTime();
                using (dbDataContext db = new dbDataContext())
                {
                    var categories = db.Categories.ToList();
                    var posts      = db.Posts.Where(n => n.Submitted == true).ToList();


                    loadScroller(posts);
                    loadCategory(categories);
                    loadCards(posts);
                    loadRecentVideo(posts);
                    loadHoroscope();
                }
            }
        }