Models/Comic
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace MvcBootstrap.Models
{
public class Comic
{
public int ID { get; set; }
public string Title { get; set; }
public int Issue { get; set; }
public string ImageURL { get; set; }
public double Price { get; set; }
public string Status { get; set; }
public Comic()
{
}
public Comic(int id, string title, int issue, string imageurl, double price, string status)
{
ID = id;
Title = title;
Issue = issue;
ImageURL = imageurl;
Price = price;
Status = status;
}
public Comic GetComicByID(int id)
{
List allComics = GetAllComics();
Comic comic = new Comic();
foreach (Comic c in allComics)
{
if (c.ID == id)
{
comic = c;
}
}
return comic;
}
public List GetComicsByTitle(string inTitle)
{
string testit = inTitle == null ? "" : inTitle.ToLower().Trim();
List allComics = GetAllComics();
List comicsByTitle = new List();
foreach (Comic c in allComics)
{
//c.ImageURL = "~/Areas/Images/Thumbnails/" + c.ImageURL;
if (String.IsNullOrEmpty(testit))
{
comicsByTitle.Add(c);
}
else
{
if (c.Title.ToLower().Contains(testit))
{
comicsByTitle.Add(c);
}
}
}
return comicsByTitle;
}
public List GetAllComics()
{
List comicList = new List();
comicList.Add(new Comic(1, "Doctor Strange", 169, "DoctorStrange169.jpg", 9.99, "avail"));
comicList.Add(new Comic(2, "Amazing Fantasy", 15, "AmazingFantasy15.jpg", 99.99, "avail"));
comicList.Add(new Comic(3, "Amazing Spider-Man", 1, "AmazingSpiderMan1.jpg", 999.99, "avail"));
comicList.Add(new Comic(4, "Captain America", 100, "CaptainAmerica100.jpg", 9999.99, "avail"));
comicList.Add(new Comic(5, "Conan The Barbarian", 1, "ConanTheBarbarian1.jpg", 99999.99, "avail"));
comicList.Add(new Comic(6, "Daredevil", 1, "Daredevil1.jpg", 9999.99, "avail"));
comicList.Add(new Comic(7, "Defenders", 1, "Defenders1.jpg", 9999999.99, "avail"));
comicList.Add(new Comic(8, "Detective", 27, "Detective27.jpg", 99999.99, "avail"));
comicList.Add(new Comic(9, "Fantastic Four", 1, "FantasticFour1.jpg", 99999.99, "avail"));
comicList.Add(new Comic(10, "Flash", 1, "Flash1.jpg", 9999.99, "avail"));
comicList.Add(new Comic(11, "Ghost Rider", 1, "GhostRider1.jpg", 9.99, "avail"));
comicList.Add(new Comic(12, "Giant-Size X-Men", 1, "GiantSizeXMen1.jpg", 999.99, "avail"));
comicList.Add(new Comic(13, "Green Lantern", 100, "GreenLantern1.jpg", 9999.99, "avail"));
comicList.Add(new Comic(14, "Incredible Hulk", 1, "IncredibleHulk1.jpg", 99999.99, "avail"));
comicList.Add(new Comic(15, "Sgt. Fury", 1, "SgtFury1.jpg", 9999.99, "avail"));
comicList.Add(new Comic(16, "Silver Surfer", 1, "SilverSurfer1.jpg", 9999999.99, "avail"));
comicList.Add(new Comic(17, "Strange Tales", 1, "StrangeTales1.jpg", 99999.99, "avail"));
comicList.Add(new Comic(18, "Strange Tales", 115, "StrangeTales115.jpg", 99999.99, "avail"));
comicList.Add(new Comic(19, "Superman", 1, "Superman1.jpg", 9999.99, "avail"));
comicList.Add(new Comic(20, "Tales Of Suspense", 39, "TalesofSuspense39.jpg", 9.99, "avail"));
comicList.Add(new Comic(21, "Tales Of Suspense", 49, "TalesofSuspense49.jpg", 9.99, "avail"));
comicList.Add(new Comic(22, "Tales To Astonish", 1, "TalesToAstonish1.jpg", 9.99, "avail"));
comicList.Add(new Comic(23, "treasury", 1, "Treasury6.jpg", 9.99, "avail"));
comicList.Add(new Comic(24, "Uncanny X-Men", 1, "UncannyX-Men1.jpg", 9.99, "avail"));
return comicList;
}
}
}