Ejemplo n.º 1
0
        public ActionResult Index()
        {
            //assign the array of comic books in the GetComicBook method to a variable
            var comicBooks = _comicBookRepository.GetComicBook();

            //then pass the array of comic books to the view, which we're able to do because of the view's model property
            return(View(comicBooks));
        }
Ejemplo n.º 2
0
        public ActionResult Detail(int?id)
        {
            if (id == null)
            {
                id = 1;
            }

            var comicBook = _comicBookRepository.GetComicBook((int)id);

            if (comicBook == null)
            {
                id        = 1;
                comicBook = _comicBookRepository.GetComicBook((int)id);
            }
            return(View(comicBook));
        }
        public ActionResult Detail(int?Id)  //actionresult is the base result type used by both RedirectResult and ContentResult
        {
            if (Id == null)
            {
                return(HttpNotFound());
            }

            //instantiate the comicbook model
            var comicBook = _comicBookRepository.GetComicBook((int)Id);

            //switch to the Detail view nad pass the comicBook model to the view
            return(View(comicBook));

            /*//if the day is tuesday, redirect to an other page
             * if (DateTime.Today.DayOfWeek == DayOfWeek.Tuesday)
             * {
             *  // return new RedirectResult("/"); As our class inherit from the Controller class, we can simplyify this using the Redirect method
             *  return Redirect("/");
             * }
             */


            //return Content("Hello");

            /* As our class inherit from the Controller class, we can simplify this using the Content method
             * return new ContentResult()
             * {
             *  Content = "Hello"
             * };
             */
        }
        public ActionResult Detail(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }

            var comicBook = _comicBookRepository.GetComicBook(id.Value);

            //var comicBook = new ComicBook()
            //{
            //    SeriesTitle = "The Amazing Spider-Man",
            //    IssueNumber = 700,
            //    DescriptionHtml = "<p>Final issue! Witness the final hours of Doctor Octopus' life and his one, last, great act of revenge! Even if Spider-Man survives... <strong>will Peter Parker?</strong></p>",
            //    Artists = new Artist[]
            //    {
            //        new Artist() { Name = "Dan Slott", Role = "Script" },
            //        new Artist() { Name = "Humberto Ramos", Role = "Pencils" },
            //        new Artist() { Name = "Victor Olazaba", Role = "Inks" },
            //        new Artist() { Name = "Edgar Delgado", Role = "Colors" },
            //        new Artist() { Name = "Chris Eliopoulos", Role = "Letters" }
            //    }
            //};

            return(View(comicBook));
        }
Ejemplo n.º 5
0
        public ActionResult Detail(int id)
        {
            //ViewBag.ComicBook = comicBook;

            //pass model, strongly typed
            return(View(ComicBookRepository.GetComicBook(id)));
        }
Ejemplo n.º 6
0
        public ActionResult Detail(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }

            var comicBook = _comicBookRepository.GetComicBook((int)id);

            //Pode setar assim ou do jeito acima
            //comicBook.SeriesTitle = "";

            /*
             *
             * ViewBag.SeriesTitle = "The Amazing Spider-Man";
             * ViewBag.IssueNumber = 700;
             * ViewBag.Description = "<p>Final issue! Witness the final hours of Doctor Octopus' life and his one, last, great act of revenge! Even if Spider-Man survives... <strong>will Peter Parker?</strong></p>";
             * ViewBag.Artists = new string[]
             * {
             *  "Script: Dan Slott",
             *  "Pencils: Humberto Ramos",
             *  "Inks: Victor Olazaba",
             *  "Colors: Edgar Delgado",
             *  "Letters: Chris Eliopoulos"
             * };
             *
             */

            //ViewBag.ComicBook = comicBook;

            return(View(comicBook));
        }
        /* Updating our parameter to be nullable by adding a question mark after int. */
        /* Therefore MVC can successfully pass null for the id parameter if an id value isn't provided as part of the request */
        public ActionResult Detail(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }
            /* Can place both ((int)id) and id.Value */
            var comicBook = _comicBookRepository.GetComicBook((int)id);

            /* ViewBag is an object provided by MVC, that allows us to pass data from our controller to a view. */
            /* Capatilize the letter after the ViewBag. since we switching from using variables to properties, */
            /* we need to capatilize the first letter of each property name. */
            /* We can see that it is of type dynamic. */
            /* This allows us to define properties on the ViewBag object, */
            /* without having to modify a class as we normally have to do. */
            /* ViewBag is one of the few real world use cases for dynamic types in C#. */

            /*ViewBag.SeriesTitle = "The Amazing Spider-Man";
             * ViewBag.IssueNumber = 700;
             * ViewBag.Description = "<p>Final issue! Witness the final hours of Doctor Octopus' life and his one, last great act of revenge! Even if Spider Man survives...<strong>will Peter Parker?</strong></p>";*/

            /* To comment out multiple lines, select the lines, hold down the ctrl + k following by c */
            /* To uncomment, select the lines, hold down ctrl + k following by u */

            return(View(comicBook));
        }
        public ActionResult Detail(int?/*makes it nullable if not provided*/ id)
        {
            #region Redirect result y ContentResult comentados

            /*if (DateTime.Today.DayOfWeek == DayOfWeek.Monday)
             * {
             *  return new RedirectResult("/");
             * }
             *
             * return new ContentResult()
             * {
             *  Content = "Hello from the cb controller"
             * };
             *
             * //return Content("Hello from the cb controller");
             * ViewBag.Title = "The Amazing Spider-Man";
             * ViewBag.IssueNumber = 700;
             * ViewBag.Description = "<p>Final issue!Witness the final hours of Doctor Octopus' life and his one, last, great act of revenge! Even if Spider-Man survives... <strong>will Peter Parker?</strong></p>";
             * ViewBag.Artists = new string[]
             * {
             *  "Script: Dan Slott",
             *  "Pencils: Humberto Ramos",
             *  "Inks: Victor Olazaba",
             *  "Colors: Edgar Delgado",
             *  "Letters: Chris Eliopoulos"
             * };*/
            #endregion
            if (id == null)
            {
                return(HttpNotFound());
            }
            var comicBook = _comicBookRepository.GetComicBook(id.Value /*You can also cast it instead*/);
            return(View(comicBook));
        }
        public ActionResult Detail(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }
            var comicBook = _comicBookRepository.GetComicBook((int)id);

            return(View(comicBook));
            //return View(comicBook);
            //ViewBag.ComicBook = comicBook;

            /*
             * if(DateTime.Today.DayOfWeek == DayOfWeek.Thursday)
             * {
             *  return Redirect("/");
             *  //return new RedirectResult("/");
             * }
             *
             * return Content("Hello from the comic books controller!");
             * //return new ContentResult()
             * //{
             * //    Content = "Hello from the comic books controller!"
             * //}; */
        }
Ejemplo n.º 10
0
        public ActionResult Detail(int?id)
        {
            //ViewBag.SeriesTitle = "";
            //ViewBag.IssueNumber = 700;
            //ViewBag.Description = "<p>Final issue Witness <h2>the final hour</h2></p>";
            //ViewBag.Artists = new string[]
            //{
            //"Script: Dan Slott",
            //"Pencils: Humberto Ramos",
            //"Inks: Victor Olazaba",
            //"Colors: Edgar Delgado",
            //"Letters: Chris Eliopoulos"
            //};
            //ViewBag.ComicBook = comicBook;
            if (id == null)

            {
                return(HttpNotFound());
            }
            var comicBook = _comciBookRepository.GetComicBook((int)id);

            return(View(comicBook));
            //if (DateTime.Today.DayOfWeek == DayOfWeek.Friday)
            //{
            //    return Redirect("/");
            //    //return new RedirectResult("/");
            //}
            //return Content("Hello from the comic books controller!");
            //return new contentresult()
            //{
            //    content = "hello from the comic books controller!"
            //};
            //return "Hello from the comic books controller!";
        }
Ejemplo n.º 11
0
        //public ContentResult Detail()
        #region
        //public ActionResult Detail()
        //{
        //    if (DateTime.Today.DayOfWeek == DayOfWeek.Sunday)
        //    {
        //        //return new RedirectResult("/");
        //        return Redirect("/");
        //    }

        //    return Content("Hello from the comic books controller.");

        //  /*  return new ContentResult()
        //    {
        //        Content = "Hello from the comic books controller."
        //    };*/
        //    //return "Hello from the comic books controller.";
        //}

        #endregion

        public ActionResult Detail(int?id)
        {
            #region old ViewBag code

            /*
             * ViewBag.SeriesTitle = "The Amazing Spider-Man";
             * ViewBag.IssueNumber = 700;
             * ViewBag.Description = "<p>Final issue! Witness the final hours of Doctor Octopus' life and his one, last, great act of revenge! Even if Spider-Man survives... <strong>will Peter Parker?</strong></p>";
             * ViewBag.Artists = new string[]
             * {
             *  "Script: Dan Slott",
             *  "Pencils: Humberto Ramos",
             *  "Inks: Victor Olazaba",
             *  "Colors: Edgar Delgado",
             *  "Letters: Chris Eliopoulos"
             * };*/
            #endregion

            if (id == null)
            {
                return(new ContentResult()
                {
                    Content = "Oops! Page doesn't exist."
                });
            }
            else
            {
                var comicBook = _comicBookRepository.GetComicBook((int)id);
                return(View(comicBook));
            }
        }
Ejemplo n.º 12
0
        public ActionResult Detail(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            var comicBook = _comicBookRepository.GetComicBook(id.Value);

/*
 *          ViewBag.SeriesTitle = "The Amazing Spider-Man";
 *          ViewBag.IssueNumber = 700;
 *          ViewBag.Description = "<p>Final issue! Witness the final hours of Doctor Octopus' life and his one, last, great act of revenge! Even if Spider-Man survives... <strong>will Peter Parker?</strong></p>";
 *          ViewBag.Artists = new string[]
 *          {
 *              "Script: Dan Slott",
 *              "Pencils: Humberto Ramos",
 *              "Inks: Victor Olazaba",
 *              "Colors: Edgar Delgado",
 *              "Letters: Chris Eliopoulos"
 *          };
 */
            return(View(comicBook));

            /*if(DateTime.Today.DayOfWeek == DayOfWeek.Tuesday){
             *  return new RedirectResult("/");
             * }
             * return new ContentResult(){
             *  Content = "Hello from the comic book controller"
             * };*/
            //return "Hello from the comic book controller";
        }
 public ActionResult Detail(int?id)
 {
     if (id == null)
     {
         return(HttpNotFound());
     }
     return(View(ComicBookRepository.GetComicBook((int)id)));
 }
 public ActionResult Detail(int?id)
 {
     if (id != null)
     {
         ComicBook comicBook = _comicBookRepo.GetComicBook((int)id);
         return(View(comicBook));
     }
     return(HttpNotFound());
 }
Ejemplo n.º 15
0
        public ActionResult Detail(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }
            var comicBook = _comicBookRepository.GetComicBook(id.Value); // When using a nullable type, you need to use the Value property to get to the underlying value, or cast it explicitly to the correct type ((int) id)

            return(View(comicBook));
        }
Ejemplo n.º 16
0
        public ActionResult Detail(int?id)
        {
            if (id == null)
            {
                return(StatusCode(404));
            }
            var comicBook = _comicBookRepository.GetComicBook((int)id);

            return(View(comicBook));
        }
Ejemplo n.º 17
0
        public ActionResult Detail(int?id)   // ? is if no id value is provided a null is past and will not through an error... we need ID but routing says id is optional.
        {
            if (id == null)
            {
                return(HttpNotFound());
            }
            var comicBook = _comicBookRepository.GetComicBook(id.Value);  // could also use (int)id

            return(View(comicBook));
        }
        public ActionResult Detail(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }
            var comicbook = _comicBookRepository.GetComicBook(id.Value);//because this is a nullabe integer type

            return(View(comicbook));
        }
        public ActionResult Detail(int?id) //action result is the base class of both redirect and content
        {
            if (id == null)
            {
                return(HttpNotFound());
            }
            var comicBook = _comicBookRepo.GetComicBook(id.Value);

            return(View(comicBook));
        }
        public ActionResult Detail(int?id) //the ? denotes that the parameter is nullable
        {
            if (id == null)
            {
                return(HttpNotFound());
            }
            var comicBook = _comicBookRepository.GetComicBook((int)id);//when using nullable parameters use .value property or explicit cast

            return(View(comicBook));
        }
Ejemplo n.º 21
0
        public ActionResult Detail(int?id)  /*? = nullable*/
        {
            if (id == null)
            {
                return(HttpNotFound());
            }
            var comicBook = _comicBookRepository.GetComicBook((int)id);

            return(View(comicBook));
        }
Ejemplo n.º 22
0
        public ActionResult Detail(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var comicBook = _comicBookRepository.GetComicBook((int)id);

            return(View(comicBook));
        }
Ejemplo n.º 23
0
        public ActionResult Detail(int?id)
        {
            //if (id == null)
            //{
            //    return HttpNotFound();
            //}
            var comicBook = _comicBookRepository.GetComicBook((int)id);

            return(View(comicBook));
        }
Ejemplo n.º 24
0
        public ActionResult Detail(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            ComicBook comicBook = _comicBookRepository.GetComicBook((int)id);

            return(View(comicBook));
        }
Ejemplo n.º 25
0
        public ActionResult Details(int?id)    //Nullable type parameter . So that if no argument passed then there should not be any error thrown.
        {
            if (id == null)
            {
                return(HttpNotFound());
            }
            var comicBook = _comicBookRepository.GetComicBook((int)id);

            return(View(comicBook));     //making strongly typed views
        }
Ejemplo n.º 26
0
        public ActionResult Detail(int?Id)
        {
            if (Id == null)
            {
                return(HttpNotFound());
            }
            var comicBook = _comicBookRepository.GetComicBook((int)Id);

            return(View(comicBook));
        }
        public ActionResult Detail(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }
            var comicBook = _comicBookRepository.GetComicBook(id.Value);

            return(View(comicBook));
        }
        public ActionResult Detail(int? id)
        {
            if (id == null)
            {
                return HttpNotFound();
            }
            var comicBook = _comicBookRepository.GetComicBook((int)id);

            return View(comicBook);
        }
Ejemplo n.º 29
0
        public ActionResult Detail(int?id)  //both ContentResult and RediectResult are within the ActionResult base class
        {
            if (id == null)
            {
                return(HttpNotFound());
            }

            var comicBook = _comicBookRepository.GetComicBook((int)id);

            return(View(comicBook));
        }
Ejemplo n.º 30
0
        public ActionResult Detail(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }

            var comicBook = _comicBookRepository.GetComicBook(id.Value); // To get at underlying value for nullable type

            return(View(comicBook));
        }