Пример #1
0
        public ActionResult TsarDeleteConfirmed(int id)
        {
            Tsars tsars = db.Tsars.Find(id);

            db.Tsars.Remove(tsars);
            db.SaveChanges();
            return(RedirectToAction("TsarList"));
        }
Пример #2
0
        // GET: Tsars/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Tsars tsars = db.Tsars.Find(id);

            if (tsars == null)
            {
                return(HttpNotFound());
            }
            return(View(tsars));
        }
Пример #3
0
        // GET: Tsars/Edit/5
        public ActionResult TsarEdit(int?id)
        {
            Tsars tsars = db.Tsars.Where(x => x.ID == id).SingleOrDefault();

            TsarVM model = new TsarVM()
            {
                ID          = tsars.ID,
                FullName    = tsars.FullName,
                Name        = tsars.TsarName,
                Predecessor = tsars.Predecessor,
                Successor   = tsars.Successor,
                Reign       = tsars.Reign,
                BirhtDate   = Convert.ToDateTime(tsars.BirthDate),
                DiedDate    = Convert.ToDateTime(tsars.DiedDate),
                Age         = Convert.ToByte(tsars.Age),
                Dynasty     = tsars.Dynasty,
                CategoryID  = Convert.ToInt32(tsars.CategoryID),
            };

            ViewBag.CategoryID = new SelectList(db.Categories, "ID", "CategoryName", tsars.CategoryID);
            return(View(model));
        }
Пример #4
0
        public ActionResult TsarCreate(TsarVM model)
        {
            if (ModelState.IsValid)
            {
                Tsars tsar = new Tsars();
                tsar.FullName    = model.FullName;
                tsar.TsarName    = model.Name;
                tsar.Predecessor = model.Predecessor;
                tsar.Successor   = model.Successor;
                tsar.Reign       = model.Reign;
                tsar.BirthDate   = model.BirhtDate;
                tsar.DiedDate    = model.DiedDate;
                tsar.Age         = Convert.ToByte(model.Age);
                tsar.Dynasty     = model.Dynasty;
                tsar.CategoryID  = model.CategoryID;

                db.Tsars.Add(tsar);
                db.SaveChanges();
                return(RedirectToAction("TsarList"));
            }

            ViewBag.CategoryID = new SelectList(db.Categories, "ID", "CategoryName", model.CategoryID);
            return(View(model));
        }