zoukankan      html  css  js  c++  java
  • 我的MVC.NET

    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Data.Entity;
    using System.Linq;
    using System.Net;
    using System.Web;
    using System.Web.Mvc;
    using myMVC.Models;
    
    namespace myMVC.Controllers
    {
        public class HomeController : Controller
        {
            private Entities db = new Entities();
    
            // GET: /Home/
            public ActionResult Index()
            {
                return View(db.myBlogSet.ToList());
            }
    
            // GET: /Home/Details/5
            public ActionResult Details(int? id)
            {
                if (id == null)
                {
                    return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
                }
                myBlogSet myblogset = db.myBlogSet.Find(id);
                if (myblogset == null)
                {
                    return HttpNotFound();
                }
                return View(myblogset);
            }
    
            // GET: /Home/Create
            public ActionResult Create()
            {
                return View();
            }
    
            // POST: /Home/Create
            // 为了防止“过多发布”攻击,请启用要绑定到的特定属性,有关 
            // 详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkId=317598
            [HttpPost]
            [ValidateAntiForgeryToken]
            public ActionResult Create([Bind(Include="Id,myblogs")] myBlogSet myblogset)
            {
                if (ModelState.IsValid)
                {
                    db.myBlogSet.Add(myblogset);
                    db.SaveChanges();
                    return RedirectToAction("Index");
                }
    
                return View(myblogset);
            }
    
            // GET: /Home/Edit/5
            public ActionResult Edit(int? id)
            {
                if (id == null)
                {
                    return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
                }
                myBlogSet myblogset = db.myBlogSet.Find(id);
                if (myblogset == null)
                {
                    return HttpNotFound();
                }
                return View(myblogset);
            }
    
            // POST: /Home/Edit/5
            // 为了防止“过多发布”攻击,请启用要绑定到的特定属性,有关 
            // 详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkId=317598
            [HttpPost]
            [ValidateAntiForgeryToken]
            public ActionResult Edit([Bind(Include="Id,myblogs")] myBlogSet myblogset)
            {
                if (ModelState.IsValid)
                {
                    db.Entry(myblogset).State = EntityState.Modified;
                    db.SaveChanges();
                    return RedirectToAction("Index");
                }
                return View(myblogset);
            }
    
            // GET: /Home/Delete/5
            public ActionResult Delete(int? id)
            {
                if (id == null)
                {
                    return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
                }
                myBlogSet myblogset = db.myBlogSet.Find(id);
                if (myblogset == null)
                {
                    return HttpNotFound();
                }
                return View(myblogset);
            }
    
            // POST: /Home/Delete/5
            [HttpPost, ActionName("Delete")]
            [ValidateAntiForgeryToken]
            public ActionResult DeleteConfirmed(int id)
            {
                myBlogSet myblogset = db.myBlogSet.Find(id);
                db.myBlogSet.Remove(myblogset);
                db.SaveChanges();
                return RedirectToAction("Index");
            }
    
            protected override void Dispose(bool disposing)
            {
                if (disposing)
                {
                    db.Dispose();
                }
                base.Dispose(disposing);
            }
        }
    }
  • 相关阅读:
    9.3 寻找magic index
    编写一个函数,确定需要改变几个位,才能将整数A转成整数B。
    打印0-1之间double数字的二进制表示
    打印二叉树节点数值总和等于某个给定节点的所有路径
    判断T2是否是T1的子树
    二棵树某两个节点的公共祖先。
    4.6 找出二叉树中指定节点的下一个节点(中序后继),假定每个节点有父指针。
    队列实现max操作,要求尽量提高效率。
    用两个stack设计一个队列
    转分享一个MAC下绕开百度网盘限速下载的方法,三步操作永久生效
  • 原文地址:https://www.cnblogs.com/makewong/p/3414715.html
Copyright © 2011-2022 走看看