Views/Home/AbstractClassIndex.cshtml
@model IEnumerable<MvcBootstrap.Models.Comics>
@{
ViewBag.Title = "Angular 1";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<div class="row col-sm-12 text-center"><h4 style="color:red;">(click on headings for code snippets)</h4></div>
<div class="row col-sm-12">
<div class="col-sm-4"></div>
<div id="dvAbstractClass" data-toggle="modal" data-target="#modalAbstractClass" class="row text-center col-sm-4"><h1>Abstract Class</h1></div>
<div class="col-sm-4"></div>
</div>
<div class="col-sm-12">
<div class="row">
<div class="col-sm-5" style="border:2px solid fuchsia;">
<div id="dv1stAbstract" data-toggle="modal" data-target="#modal1stAbstract" class="row text-center"><h2>Using 1st Abstract Implementation</h2></div>
@foreach (var item in ViewBag.ComicsList2)
{
<div class="row" style="padding-left:25px;">
@item.Title @item.Issue
</div>
}
</div>
<div class="col-sm-1"></div>
<div class="col-sm-5" style="border:2px solid fuchsia;">
<div id="dv2ndAbstract" data-toggle="modal" data-target="#modal2ndAbstract" class="row text-center"><h2>Using 1st NonAbstract Method</h2></div>
@if (ViewBag.ComicsList1 != null)
{
foreach (var c in ViewBag.ComicsList1)
{
<div class="row" style="padding-left:25px;">
@c.Title @c.Issue
</div>
}
}
</div>
<div class="col-sm-1"></div>
</div>
<div class="row col-sm-12" style="height:10px;"></div>
<div class="row">
<div class="col-sm-5" style="border:2px solid fuchsia;">
<div id="dv3rdAbstract" data-toggle="modal" data-target="#modal3rdAbstract" class="row text-center"><h2>Using 2nd Abstract Implementation</h2></div>
@foreach (var item in ViewBag.ComicsList4)
{
<div class="row" style="padding-left:25px;">
@item.Title @item.Issue
</div>
}
</div>
<div class="col-sm-1"></div>
<div class="col-sm-5" style="border:2px solid fuchsia;">
<div id="dv4thAbstract" data-toggle="modal" data-target="#modal4thAbstract" class="row text-center"><h2>Using 2nd NonAbstract Method</h2></div>
@if (ViewBag.ComicsList1 != null)
{
foreach (var c in ViewBag.ComicsList3)
{
<div class="row" style="padding-left:25px;">
@c.Title @c.Issue
</div>
}
}
</div>
<div class="col-sm-1"></div>
</div>
@*Abstract Modal*@
<div id="modalAbstractClass" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"> × </button>
<h4 class="modal-title text-center"> Abstract Class snippet </h4>
</div>
<div class="modal-body">
<form class="form-horizontal" role="form" method="post">
<div class="form-group" style="font-weight:bold;">
<pre>
//Abstract Classes can not be instantiate
//however, multiple Derived Classes can be
public abstract class AbstractComicClass
{
//Abstract method: will require implementation in derived class
public abstract List<Comics> GetAllComicsAbstract();
//non-Abstract method: will not require implementation
public List<Comics> GetAllComicsNonAbstract()
{
AlbacoreComicsDB db = new AlbacoreComicsDB();
List<Comics> comicsList = db.Comics.OrderByDescending(c=> c.Title).ToList();
return comicsList;
}
}
</pre>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"> Close </button>
</div>
</div>
</div>
</div>
@*1st Abstract Modal*@
<div id="modal1stAbstract" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
×
</button>
<h4 class="modal-title text-center">
1st Derived Class - implementing abstract method
</h4>
</div>
<div class="modal-body">
<form class="form-horizontal" role="form" method="post">
<div class="form-group">
<pre>
//Abstract Classes can not be instantiate
//however, multiple instances of a Derived Class can be
//Derived AbstractComicClass
class AbstractComicClassDerived : AbstractComicClass
{
//implement abstract method GetAllComicsAbstract
public override List<Comics> GetAllComicsAbstract()
{
AlbacoreComicsDB db = new AlbacoreComicsDB();
Comic comic = new Comic();
List<Comics> comicsList = db.Comics.OrderByDescending(c=> c.Title).ToList();
return comicsList;
}
} //end of Derived Class
//instantiation 1 of Derived Class
AbstractComicClassDerived child1 = new AbstractComicClassDerived();
//use Abstract method of child1 Derived Class
List<Comics> comicsList1 = child1.GetAllComicsAbstract();
//pass return of implementation to ViewBag
ViewBag.ComicsList1 = comicsList1;
</pre>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">
Close
</button>
</div>
</div>
</div>
</div>
@*2nd Abstract Modal*@
<div id="modal2ndAbstract" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
×
</button>
<h4 class="modal-title text-center">
1st Derived Class - calling non-abstract method
</h4>
</div>
<div class="modal-body">
<form class="form-horizontal" role="form" method="post">
<div class="form-group">
<pre>
//Abstract Classes can not be instantiate
//however, multiple instances of a Derived Class can be
//Derived AbstractComicClass
class AbstractComicClassDerived : AbstractComicClass
{
//implement abstract method GetAllComicsAbstract
public override List<Comics> GetAllComicsAbstract()
{
AlbacoreComicsDB db = new AlbacoreComicsDB();
Comic comic = new Comic();
List<Comics> comicsList = db.Comics.OrderByDescending(c=> c.Title).ToList();
return comicsList;
}
} //end of derived class
//instantiation 1 of Derived Class
AbstractComicClassDerived child1 = new AbstractComicClassDerived();
//use non-Abstract method of child1 Derived Class
List<Comics> comicsList2 = child1.GetAllComicsNonAbstract();
//pass return from method to ViewBag
ViewBag.ComicsList2 = comicsList2;
</pre>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">
Close
</button>
</div>
</div>
</div>
</div>
@*3rd Abstract Modal*@
<div id="modal3rdAbstract" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
×
</button>
<h4 class="modal-title text-center">
2nd Derived Class - implementing abstract method
</h4>
</div>
<div class="modal-body">
<form class="form-horizontal" role="form" method="post">
<div class="form-group">
<pre>
//Abstract Classes can not be instantiate
//however, multiple instances of a Derived Class can be
//Derived AbstractComicClass
class AbstractComicClassDerived : AbstractComicClass
{
//implement abstract method GetAllComicsAbstract
public override List<Comics> GetAllComicsAbstract()
{
AlbacoreComicsDB db = new AlbacoreComicsDB();
Comic comic = new Comic();
List<Comics> comicsList = db.Comics.OrderByDescending(c=> c.Title).ToList();
return comicsList;
}
} //end of derived class
//instantiation 2 of Derived Class
AbstractComicClassDerived child2 = new AbstractComicClassDerived();
//use Abstract method of child2 Derived Class
List<Comics> comicsList3 = child2.GetAllComicsAbstract();
//pass return of implementation to ViewBag
ViewBag.ComicsList3 = comicsList3;
</pre>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">
Close
</button>
</div>
</div>
</div>
</div>
@*4th Abstract Modal*@
<div id="modal4thAbstract" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
×
</button>
<h4 class="modal-title text-center">
2nd Derived Class - calling non-abstract method
</h4>
</div>
<div class="modal-body">
<form class="form-horizontal" role="form" method="post">
<div class="form-group">
<pre>
//Abstract Classes can not be instantiate
//however, multiple instances of a Derived Class can be
//Derived AbstractComicClass
class AbstractComicClassDerived : AbstractComicClass
{
//implement abstract method GetAllComicsAbstract
public override List<Comics> GetAllComicsAbstract()
{
AlbacoreComicsDB db = new AlbacoreComicsDB();
Comic comic = new Comic();
List<Comics> comicsList = db.Comics.OrderByDescending(c=> c.Title).ToList();
return comicsList;
}
} //end of derived class
//instantiation 2 of Derived Class
AbstractComicClassDerived child2 = new AbstractComicClassDerived();
//use non-Abstract method of child2 Derived Class
List<Comics> comicsList4 = child2.GetAllComicsNonAbstract();
//pass return of method to ViewBag
ViewBag.ComicsList4 = comicsList4;
</pre>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">
Close
</button>
</div>
</div>
</div>
</div>
</div>