Ejemplo n.º 1
0
        // GET: Prompt
        public ActionResult Index()
        {
            var service = new PromptServices();
            var model   = service.GetPrompts();

            return(View(model));
        }
Ejemplo n.º 2
0
        public ActionResult DeletePost(int id)
        {
            var service = new PromptServices();

            service.DeletePrompt(id);
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 3
0
        public ActionResult Delete(int id)
        {
            var service = new PromptServices();

            var model = service.GetPromptById(id);

            return(View(model));
        }
Ejemplo n.º 4
0
        public PromptItem GetPrompt(int id)
        {
            var service = new PromptServices();

            var model = service.GetPromptById(id);

            return(new PromptItem
            {
                Prompt = model.Prompt
            });
        }
Ejemplo n.º 5
0
        public ActionResult Edit(int id)
        {
            var service = new PromptServices();

            var prompt = service.GetPromptById(id);

            var model =
                new PromptEdit
            {
                PromptId = prompt.PromptId,
                Category = prompt.Category,
                Prompt   = prompt.Prompt
            };

            return(View(model));
        }
Ejemplo n.º 6
0
        public ActionResult Create(PromptCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var service = new PromptServices();

            if (service.CreatePrompt(model))
            {
                TempData["SaveResult"] = "Your entry was created.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Prompt could not be created.");
            return(View(model));
        }
Ejemplo n.º 7
0
        public ActionResult Edit(int id, PromptEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            if (model.PromptId != id)
            {
                ModelState.AddModelError("", "Sorry, looks like we didn't find a Prompt with that Id.");
                return(View(model));
            }
            var service = new PromptServices();

            if (service.UpdatePrompt(model))
            {
                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError("", "Prompt could not be updated.");
            return(View(model));
        }