public ActionResult Delete(int id) { //We show a specific delete confirmation with the blog entry information DoctorsBlog blog = db.DoctorsBlogs.SqlQuery("select * from DoctorsBlogs where BlogId=@BlogId", new SqlParameter("@BlogId", id)).FirstOrDefault(); return(View(blog)); }
public ActionResult PublicShow(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } //EF 6 technique DoctorsBlog doctorsblog = db.DoctorsBlogs.SqlQuery("select * from DoctorsBlogs where BlogId=@BlogId", new SqlParameter("@BlogId", id)).FirstOrDefault(); if (doctorsblog == null) { return(HttpNotFound()); } string topic_query = "select * from BlogTopics inner join BlogTopicDoctorsBlogs on BlogTopics.TopicId = BlogTopicDoctorsBlogs.BlogTopic_TopicId where BlogTopicDoctorsBlogs.DoctorsBlog_BlogId=@BlogId"; var t_parameter = new SqlParameter("@BlogId", id); List <BlogTopic> usedtopics = db.Topics.SqlQuery(topic_query, t_parameter).ToList(); AddBlogTopic viewmodel = new AddBlogTopic(); viewmodel.Blog = doctorsblog; viewmodel.BlogTopics = usedtopics; return(View(viewmodel)); }
public ActionResult Show(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } //EF 6 technique DoctorsBlog doctorsblog = db.DoctorsBlogs.SqlQuery("select * from DoctorsBlogs where BlogId=@BlogId", new SqlParameter("@BlogId", id)).FirstOrDefault(); if (doctorsblog == null) { return(HttpNotFound()); } string topic_query = "select * from BlogTopics inner join BlogTopicDoctorsBlogs on BlogTopics.TopicId = BlogTopicDoctorsBlogs.BlogTopic_TopicId where BlogTopicDoctorsBlogs.DoctorsBlog_BlogId=@BlogId"; var t_parameter = new SqlParameter("@BlogId", id); List <BlogTopic> usedtopics = db.Topics.SqlQuery(topic_query, t_parameter).ToList(); string all_topics_query = "select * from BlogTopics"; List <BlogTopic> AllTopics = db.Topics.SqlQuery(all_topics_query).ToList(); // We use the AddBlogTopic viewmodel so that we can show the topics that are on that blog post and also so that we can see the dropdown list of topics // so that the user can add a topic AddBlogTopic viewmodel = new AddBlogTopic(); viewmodel.Blog = doctorsblog; viewmodel.BlogTopics = usedtopics; viewmodel.Add_Topic = AllTopics; return(View(viewmodel)); }
public ActionResult Update(int id) { //need information about a particular blog entry DoctorsBlog selectedblog = db.DoctorsBlogs.SqlQuery("select * from DoctorsBlogs where BlogId=@BlogId", new SqlParameter("@BlogId", id)).FirstOrDefault(); string topic_query = "select * from BlogTopics inner join BlogTopicDoctorsBlogs on BlogTopics.TopicId = BlogTopicDoctorsBlogs.BlogTopic_TopicId where BlogTopicDoctorsBlogs.DoctorsBlog_BlogId=@BlogId"; var t_parameter = new SqlParameter("@BlogId", id); List <BlogTopic> usedtopics = db.Topics.SqlQuery(topic_query, t_parameter).ToList(); //We use the AddBlogTopic viewmodel to show the topics. AddBlogTopic AddBlogTopicViewModel = new AddBlogTopic(); AddBlogTopicViewModel.Blog = selectedblog; AddBlogTopicViewModel.BlogTopics = usedtopics; return(View(AddBlogTopicViewModel)); }