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);
            }
        }
    }
  • 相关阅读:
    BZOJ 3555: [Ctsc2014]企鹅QQ hash
    bzoj 4300: 绝世好题 dp
    Codeforces Round #192 (Div. 1) C. Graph Reconstruction 随机化
    Codeforces Round #192 (Div. 1) B. Biridian Forest 暴力bfs
    Codeforces Round #192 (Div. 1) A. Purification 贪心
    HDU 5514 Frogs 容斥定理
    HDU 5515 Game of Flying Circus 二分
    HDU 5521 Meeting 最短路
    HDU 5510 Bazinga 暴力匹配加剪枝
    HDU 5512 Meeting 博弈论
  • 原文地址:https://www.cnblogs.com/makewong/p/3414715.html
Copyright © 2011-2022 走看看