Exemplo n.º 1
0
        //
        // GET: /Event/Create
        public ActionResult Create()
        {
            var type = from t in db.Types select t;
            int number = type.Count<EType>();
            if (number == 0)
            {
                EType et1 = new EType();
                EType et2 = new EType();
                EType et3 = new EType();
                EType et4 = new EType();
                EType et5 = new EType();
                et1.type = "breakfast";
                db.Types.Add(et1);
                db.SaveChanges();
                et2.type = "lunch";
                db.Types.Add(et2);
                db.SaveChanges();
                et3.type = "dinner";
                db.Types.Add(et3);
                db.SaveChanges();
                et4.type = "party";
                db.Types.Add(et4);
                db.SaveChanges();
                et5.type = "others";
                db.Types.Add(et5);
                db.SaveChanges();
            }

            var status = from m in db.Status select m;
            int number2 = status.Count<Status>();
            if (number == 0)
            {

                Status s1 = new Status();
                Status s2 = new Status();
                Status s3 = new Status();
                Status s4 = new Status();
                Status s5 = new Status();
                s1.status = "open";
                db.Status.Add(s1);
                db.SaveChanges();
                s2.status = "close";
                db.Status.Add(s2);
                db.SaveChanges();
                s3.status = "lock";
                db.Status.Add(s3);
                db.SaveChanges();
                s4.status = "unlock";
                db.Status.Add(s4);
                db.SaveChanges();
                s5.status = "pending";
                db.Status.Add(s5);
                db.SaveChanges();
            }

            ViewBag.StatusID = new SelectList(db.Status, "StatusID", "status");
            ViewBag.TypeID = new SelectList(db.Types, "TypeID", "type");
            return View();
        }
Exemplo n.º 2
0
 public ActionResult Addtype(object sender, EventArgs e)
 {
     string typename = Request.Form["typename"];
     EType et = new EType();
     et.type = typename;
     db.Types.Add(et);
     db.SaveChanges();
     return RedirectToAction("Create");
 }