示例#1
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (FileUpload1.HasFile)
     {
         try
         {
             string filename = System.IO.Path.GetFileName(FileUpload1.FileName);
             FileUpload1.SaveAs(Server.MapPath("~/images/blog/") + filename);
             StatusLabel.Text = "Upload status: File uploaded!";
         }
         catch (Exception ex)
         {
             StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
         }
     }
     using (DBInteractiobDataContext context = new DBInteractiobDataContext())
     {
         Post p = new Post();
         p.posttitle      = TextBox1.Text;
         p.writtencontent = TextBox2.Text;
         p.userid         = Convert.ToInt32(DropDownList1.Text);
         p.cuisineid      = Convert.ToInt32(DropDownList2.Text);
         p.headerimage    = FileUpload1.FileName;
         p.date_added     = DateTime.Now.ToLocalTime();
         context.Posts.InsertOnSubmit(p);
         context.SubmitChanges();
         Response.Write("<script>alert('inserted successfully!!');</script>");
     }
 }
示例#2
0
        protected void LoadCommentsForPost()
        {
            if (p != null)
            {
                DBInteractiobDataContext dc = new DBInteractiobDataContext();
                var commentList             = from n in dc.Comments
                                              where n.postsid == p.postsid
                                              select n;
                total.Text = commentList.Count() + " Comments";
                List <Comment> comments = commentList.ToList();
                foreach (Comment comment in comments)
                {
                    var u = from c in dc.Users
                            where c.userid == comment.user_id
                            select c;


                    if (u.Count() == 0)
                    {
                        CommentList.InnerHtml = CommentList.InnerHtml + $"<li class='wow fadeInUp'><img src = 'images/default-avatar.png' alt = '' /><div class='comment-details'><div class='comments'><div class='comment-meta'><div class='user-name'>Anonymous</div><div class='posted-date'>{comment.date_added}</div></div><p>{comment.comments}</p></div></div></li>";
                    }
                    else
                    {
                        User user = (User)u.First();
                        CommentList.InnerHtml = CommentList.InnerHtml + $"<li class='wow fadeInUp'><img src = 'images/{user.img}' alt = '' /><div class='comment-details'><div class='comments'><div class='comment-meta'><div class='user-name'>{user.name}</div><div class='posted-date'>{comment.date_added}</div></div><p>{comment.comments}</p></div></div></li>";
                    }
                }
            }
            else
            {
                Response.Redirect("~/BlogLoader.aspx");
            }
        }
示例#3
0
        public void commentinsertion()
        {
            DBInteractiobDataContext dc = new DBInteractiobDataContext();

            dc.Comments.InsertOnSubmit(c);

            dc.SubmitChanges();
        }
示例#4
0
        public static IEnumerable <User> login(string name, string pass)
        {
            DBInteractiobDataContext dc = new DBInteractiobDataContext();
            var u = from n in dc.Users
                    where n.username == name &&
                    n.pass == pass
                    select n;

            return(u);
        }
 protected void Submit_Click(object sender, EventArgs e)
 {
     using (DBInteractiobDataContext Ratingcontext = new DBInteractiobDataContext())
     {
         RatingValue rv = new RatingValue();
         rv.ratingvalue1 = TextBox1.Text;
         Ratingcontext.RatingValues.InsertOnSubmit(rv);
         Ratingcontext.SubmitChanges();
         Response.Write("<script>alert('inserted successfully!!');</script>");
     }
 }
示例#6
0
 protected void RatingButton_Click(object sender, EventArgs e)
 {
     using (DBInteractiobDataContext Ratingcontext1 = new DBInteractiobDataContext())
     {
         Rating r = new Rating();
         r.postsid       = Convert.ToInt32(DropDownListPost.Text);
         r.ratingvalueid = Convert.ToInt32(DropDownListRValue.Text);
         Ratingcontext1.Ratings.InsertOnSubmit(r);
         Ratingcontext1.SubmitChanges();
         Response.Write("<script>alert('inserted successfully!!');</script>");
     }
 }
 protected void SubmitButton_Click1(object sender, EventArgs e)
 {
     using (DBInteractiobDataContext context1 = new DBInteractiobDataContext())
     {
         Cuisine cu = new Cuisine();
         Response.Write("In");
         cu.cuisinename = CuisineNameTextBox.Text;
         context1.Cuisines.InsertOnSubmit(cu);
         context1.SubmitChanges();
         Response.Write("<script>alert('inserted successfully!!');</script>");
     }
 }
 protected void Button1_Click(object sender, EventArgs e)
 {
     using (DBInteractiobDataContext Newslettercontext = new DBInteractiobDataContext())
     {
         Newsletter n = new Newsletter();
         n.newstitle   = TextBox1.Text;
         n.newssubject = TextBox2.Text;
         n.newscontent = TextBox3.Text;
         n.header      = TextBox4.Text;
         n.footer      = TextBox5.Text;
         Newslettercontext.Newsletters.InsertOnSubmit(n);
         Newslettercontext.SubmitChanges();
         Response.Write("<script>alert('inserted successfully!!');</script>");
     }
 }
示例#9
0
 protected void UpdateImage(User u)
 {
     try
     {
         DBInteractiobDataContext dc = new DBInteractiobDataContext();
         string filename             = FileUpload1.FileName;
         FileUpload1.SaveAs(Server.MapPath("~/images/") + filename);
         u.img = filename;
         dc.SubmitChanges();
     }
     catch (Exception exc)
     {
         Response.Write("<script>alert('Some error occurred. Please Try later.');</script>");
     }
 }
示例#10
0
        protected void LoadCuisineList()
        {
            using (DBInteractiobDataContext dc = new DBInteractiobDataContext())
            {
                var list = from n in dc.Cuisines
                           select n;

                List <Cuisine> cuisines = list.ToList();

                foreach (Cuisine cuisine in cuisines)
                {
                    CuisineList.InnerHtml = CuisineList.InnerHtml + $"<li><h3><a href='BlogLoader.aspx?cuisine={cuisine.cuisineid}'>{cuisine.cuisinename}</h3></li>";
                }
            }
        }
示例#11
0
        public bool addUser()
        {
            DBInteractiobDataContext dc = new DBInteractiobDataContext();

            dc.Users.InsertOnSubmit(u);

            try
            {
                dc.SubmitChanges();
                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
示例#12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                List <Post> postlist        = null;
                DBInteractiobDataContext dc = new DBInteractiobDataContext();
                var posts = from a in dc.Posts
                            select a;
                //Deciding how to populate shiza
                if (Request.QueryString["cuisine"] != null)
                {
                    postlist = posts.Where(x => x.cuisineid == Convert.ToInt32(Request.QueryString["cuisine"])).ToList();
                }
                else if (Request.QueryString["cuisine"] == null)
                {
                    postlist = posts.ToList();
                }

                foreach (var post in postlist)
                {
                    var u = from n in dc.Users
                            where n.userid == post.userid
                            select n;
                    User user = (User)u.First();
                    PostArea.InnerHtml = PostArea.InnerHtml + $"<div class='col-md-8'><div class='post-item wow' style='padding:10px;' data-animation='fadeInUp' data-animation-delay='300'> <br><h2 style='padding-top:20px;' class='wow fadeInUp'><a href = 'BlogPage.aspx?id={post.postsid}'>{post.posttitle}</a></h2> <div class='post wow fadeInUp'> <a href = 'BlogPage.aspx?id={post.postsid}'><img height='350px' width='745px' src='images/blog/{post.headerimage}' alt='blog /></a> <div class='post-content'><p>..{post.writtencontent.Substring(post.writtencontent.Length - 360)}</p> <div class='posted-date'>{post.date_added}   /   <span>by</span> <a href = '#' >{user.name}</a> </div></div></div></div>";
                }
                //Populating Popular Posts with Random Posts
                Random      rnd      = new Random();
                List <Post> tempList = posts.OrderBy(user => rnd.Next()).Take(3).ToList();

                foreach (var post in tempList)
                {
                    PopularList.InnerHtml = PopularList.InnerHtml + $"<li><a href = 'BlogPage.aspx?id={post.postsid}'><img src = 'images/blog/{post.headerimage}' height = '84px' width = '82px' alt = '' /><div class='content'><h3>{post.posttitle}</h3><div class='posted-date'>{post.date_added}</div></div></a></li>";
                }

                //Populating Most Recent Posts with Latest Posts
                tempList = posts.OrderByDescending(x => x.postsid).Take(3).ToList();
                foreach (var post in tempList)
                {
                    RecentList.InnerHtml = RecentList.InnerHtml + $"<li><a href = 'BlogPage.aspx?id={post.postsid}'><img src = 'images/blog/{post.headerimage}' height = '84px' width = '82px' alt = '' /><div class='content'><h3>{post.posttitle}</h3><div class='posted-date'>{post.date_added}</div></div></a></li>";
                }

                //Loading Cuisines List
                LoadCuisineList();
            }
        }
示例#13
0
        protected void SubmitOnClick(object sender, EventArgs e)
        {
            var value = Convert.ToInt32(Request.QueryString["id"]);
            DBInteractiobDataContext dc = new DBInteractiobDataContext();
            Comment comm = new Comment();

            var post = from pi in dc.Posts
                       where pi.postsid == value
                       select pi;

            p = post.First();

            comm.comments   = message.Text;
            comm.postsid    = p.postsid;
            comm.date_added = DateTime.Now;

            u = (User)Session["user"];
            if (u != null)
            {
                int id = u.userid;
                comm.user_id = id;
            }
            else
            {
                comm.user_id = null;
            }



            CommentPostMapper cpm = new CommentPostMapper(p, comm);

            //CALL INSERTION FUNCTION HERE
            cpm.commentinsertion();

            // alert
            string mess   = "Thank you for the comment.";
            string script = "window.onload = function(){ alert('";

            script += mess;
            script += "');";
            script += "window.location = '";
            script += Request.Url.AbsoluteUri;
            script += "'; }";
            ClientScript.RegisterStartupScript(this.GetType(), "SuccessMessage", script, true);
        }
示例#14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["id"] != null)
            {
                var value = Convert.ToInt32(Request.QueryString["id"]);
                DBInteractiobDataContext dc = new DBInteractiobDataContext();

                //Fetching the post
                var post = from a in dc.Posts
                           where a.postsid == value
                           select a;

                if (post == null)
                {
                    Response.Redirect("~/BlogLoader.aspx");
                }
                p = (Post)post.First();

                //Fetching the author
                var userRaw = from n in dc.Users
                              where n.userid == p.userid
                              select n;
                if (userRaw == null)
                {
                    u = null;
                }
                else
                {
                    u = (User)userRaw.First();
                }

                LoadBlogComponents();
                LoadCommentsForPost();
                LoadSideBar();
            }
            else
            {
                Response.Write("<script>alert('Invalid page requested.');</script>");
                Response.Redirect("~/BlogLoader.aspx");
            }
        }
示例#15
0
        protected void LoadBlogComponents()
        {
            using (DBInteractiobDataContext dc = new DBInteractiobDataContext())
            {
                //Fetching post data and displaying it
                if (p != null && u != null)
                {
                    lb1.Text      = p.posttitle;
                    lb2.Text      = p.writtencontent;
                    headimage.Src = "~/images/blog/" + p.headerimage;

                    var cui = from a in dc.Cuisines
                              where a.cuisineid == p.cuisineid
                              select a;

                    Cuisine c = (Cuisine)cui.First();

                    authorData.InnerHtml    = $"<img class='img-responsive' height='100px' width='300px' src = '{u.img}' alt='{u.name}'><div class='author-comment'><h3 style='padding-left:20px'>{u.name}</h3><h5 style='padding-left:20px'>{u.email}</h5></div><div class='clear'></div>";
                    detailSection.InnerHtml = $"{p.date_added} / <span>by<span> {u.name} / {c.cuisinename}";
                }
            }
        }
示例#16
0
 protected void Button1_Click1(object sender, EventArgs e)
 {
     using (DBInteractiobDataContext Feedbackcontext = new DBInteractiobDataContext())
     {
         Feedback f = new Feedback();
         f.feedbackname    = NameTextBox.Value;
         f.feedbackemail   = EmailTextBox.Value;
         f.feedbackmessage = MessageTextArea.Value;
         f.feedbacksubject = SubjectTextBox.Value;
         Feedbackcontext.Feedbacks.InsertOnSubmit(f);
         try
         {
             Feedbackcontext.SubmitChanges();
             Response.Write("<script>alert('Thank you for your feedback. We\'ll revert to you shortly.');</script>");
             this.Page.Form.Dispose();
         }
         catch (Exception err)
         {
             Response.Write("<script>alert('An error occurred. We\'re sorry. Please try later.');</script>");
         }
     }
 }
示例#17
0
        protected void LoadSideBar()
        {
            using (DBInteractiobDataContext dc = new DBInteractiobDataContext())
            {
                //Fetching post data and displaying it
                if (p != null && u != null)
                {
                    var posts = from n in dc.Posts
                                where n.cuisineid == p.cuisineid
                                select n;
                    Random      rnd      = new Random();
                    List <Post> templist = posts.OrderBy(user => rnd.Next()).Take(3).ToList();

                    foreach (Post post in templist)
                    {
                        RelatedPosts.InnerHtml = RelatedPosts.InnerHtml + $"<li><a href = 'BlogPage.aspx?id={post.postsid}'><img src = 'images/blog/{post.headerimage}' height='84px' width = '82px' alt = '' /></a><div class='content'><h3>{post.posttitle}</h3><div class='posted-date'>{post.date_added}</div></div></li>";
                    }

                    templist = posts.OrderByDescending(x => x.postsid).Take(3).ToList();
                    foreach (var post in templist)
                    {
                        RecentList.InnerHtml = RecentList.InnerHtml + $"<li><a href = 'BlogPage.aspx?id={post.postsid}'><img src = 'images/blog/{post.headerimage}' height = '84px' width = '82px' alt = '' /><div class='content'><h3>{post.posttitle}</h3><div class='posted-date'>{post.date_added}</div></div></a></li>";
                    }

                    var list = from n in dc.Cuisines
                               select n;

                    List <Cuisine> cuisines = list.ToList();

                    foreach (Cuisine cuisine in cuisines)
                    {
                        CuisineList.InnerHtml = CuisineList.InnerHtml + $"<li><h3><a href='BlogLoader.aspx?cuisine={cuisine.cuisineid}'>{cuisine.cuisinename}</h3></li>";
                    }
                }
            }
        }