Пример #1
0
 public TbType ConvertTyp(TypViewModel tbtype)
 {
     return new TbType()
     {
         TbTypeID = tbtype.TypID,
         Name = tbtype.TypName
     };
 }
Пример #2
0
        public ActionResult Create(TypViewModel tbtype)
        {
            var typ = convert.ConvertTyp(tbtype);

            if (ModelState.IsValid)
            {
                db.TbTypes.Add(typ);
                db.SaveChanges();
                return RedirectToAction("Index1");
            }

            return View(typ);
        }
Пример #3
0
        public ActionResult Edit(TypViewModel tbtype)
        {
            if (ModelState.IsValid)
            {
                TbType tbtypeOrg = db.TbTypes.First(p => p.TbTypeID == tbtype.TypID);
                tbtypeOrg.Name = tbtype.TypName;

                db.SaveChanges();
                return RedirectToAction("Index1");
            }
            return View(tbtype);
        }
Пример #4
0
        //
        // GET: /TbType/
        public ViewResult Index1()
        {
            var mymodel = new TypViewModel();
            mymodel.TypAll = db.TbTypes.ToList();

            return View(mymodel);
        }