Exemplo n.º 1
0
        // GET: Queen
        public ActionResult Index()
        {
            var service = new QueenService();
            var model   = service.GetQueens();

            return(View(model));
        }
Exemplo n.º 2
0
        // GET: Queen/Delete/5
        public ActionResult Delete(int id)
        {
            var svc   = new QueenService();
            var model = svc.GetQueenById(id);

            return(View(model));
        }
Exemplo n.º 3
0
        public ActionResult DeleteConfirmed(int id)
        {
            var service = new QueenService();

            service.DeleteQueen(id);
            TempData["SaveResult"] = "Your Queen was deleted. May she return soon.";

            return(RedirectToAction("Index"));
        }
Exemplo n.º 4
0
        // GET: Queen/Edit/5
        public ActionResult Edit(int id)
        {
            var service = new QueenService();
            var detail  = service.GetQueenById(id);
            var model   =
                new QueenEdit
            {
                Age            = detail.Age,
                Color          = detail.Color,
                OriginDate     = detail.OriginDate,
                OriginLocation = detail.OriginLocation,
            };

            return(View(model));
        }
Exemplo n.º 5
0
        public ActionResult Create(QueenCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = new QueenService();

            if (service.CreateQueen(model))
            {
                TempData["SaveResult"] = "Your Queen was created.";
                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError("", "Queen could not be created.");
            return(View(model));
        }
Exemplo n.º 6
0
        public ActionResult Edit(int id, QueenEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.Id != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }

            var service = new QueenService();

            if (service.UpdateQueen(model))
            {
                TempData["SaveResult"] = "Your Queen was added. Long live the Queen.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Your Queen could not be added.");
            return(View(model));
        }