Skip to content

Commit b344c8b

Browse files
committed
Major improvements
1 parent 86a0271 commit b344c8b

32 files changed

+391
-68
lines changed

BookCollection.Tests/BookCollection.Tests.csproj

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<DefineConstants>DEBUG;TRACE</DefineConstants>
2424
<ErrorReport>prompt</ErrorReport>
2525
<WarningLevel>4</WarningLevel>
26+
<UseVSHostingProcess>true</UseVSHostingProcess>
2627
</PropertyGroup>
2728
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
2829
<DebugType>pdbonly</DebugType>
@@ -34,7 +35,9 @@
3435
</PropertyGroup>
3536
<ItemGroup>
3637
<Reference Include="Microsoft.CSharp" />
37-
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
38+
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
39+
<Private>False</Private>
40+
</Reference>
3841
<Reference Include="System" />
3942
<Reference Include="System.ComponentModel.DataAnnotations" />
4043
<Reference Include="System.Configuration" />
@@ -82,6 +85,8 @@
8285
</Reference>
8386
</ItemGroup>
8487
<ItemGroup>
88+
<Compile Include="Helpers\ConvertersTest.cs" />
89+
<Compile Include="Helpers\ValidatorsTest.cs" />
8590
<Compile Include="Properties\AssemblyInfo.cs" />
8691
<Compile Include="Controllers\HomeControllerTest.cs" />
8792
</ItemGroup>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using BookCollection.Helpers;
2+
using Microsoft.VisualStudio.TestTools.UnitTesting;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
9+
namespace BookCollection.Tests.Helpers
10+
{
11+
[TestClass]
12+
public class ConvertersTest
13+
{
14+
[TestMethod]
15+
public void TestRemovalOfSerieNr()
16+
{
17+
Assert.AreEqual("", Converters.RenoveSerieNr(null));
18+
Assert.AreEqual("", Converters.RenoveSerieNr(""));
19+
Assert.AreEqual("Serie XYZ", Converters.RenoveSerieNr("Serie XYZ (1)"));
20+
21+
}
22+
}
23+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using Microsoft.VisualStudio.TestTools.UnitTesting;
3+
using BookCollection.Helpers;
4+
5+
namespace BookCollection.Tests.Helpers
6+
{
7+
[TestClass]
8+
public class ValidatorsTest
9+
{
10+
[TestMethod]
11+
public void IsValidIsbnTest()
12+
{
13+
Assert.IsFalse(Validators.IsValidIsbn(""));
14+
15+
Assert.IsFalse(Validators.IsValidIsbn("1901259099"));
16+
Assert.IsTrue(Validators.IsValidIsbn("1-901259-09-9"));
17+
Assert.IsTrue(Validators.IsValidIsbn("ISBN 1-901259-09-9"));
18+
}
19+
}
20+
}

BookCollection/App_Start/BundleConfig.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ public static void RegisterBundles(BundleCollection bundles)
2121

2222
bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
2323
"~/Scripts/bootstrap.js",
24-
"~/Scripts/respond.js"));
24+
"~/Scripts/respond.js",
25+
"~/Scripts/_bookCollecion.js"));
2526

2627
bundles.Add(new StyleBundle("~/Content/css").Include(
2728
"~/Content/bootstrap.css",

BookCollection/BookCollection.csproj

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<DefineConstants>DEBUG;TRACE</DefineConstants>
3535
<ErrorReport>prompt</ErrorReport>
3636
<WarningLevel>4</WarningLevel>
37+
<UseVSHostingProcess>true</UseVSHostingProcess>
3738
</PropertyGroup>
3839
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
3940
<DebugType>pdbonly</DebugType>
@@ -64,9 +65,21 @@
6465
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll</HintPath>
6566
<Private>True</Private>
6667
</Reference>
68+
<Reference Include="FluentBootstrap, Version=3.3.5.1, Culture=neutral, processorArchitecture=MSIL">
69+
<HintPath>..\packages\FluentBootstrap.3.3.5.1\lib\net40\FluentBootstrap.dll</HintPath>
70+
<Private>True</Private>
71+
</Reference>
72+
<Reference Include="FluentBootstrap.Mvc, Version=3.3.5.1, Culture=neutral, processorArchitecture=MSIL">
73+
<HintPath>..\packages\FluentBootstrap.Mvc.3.3.5.1\lib\net40\FluentBootstrap.Mvc.dll</HintPath>
74+
<Private>True</Private>
75+
</Reference>
6776
<Reference Include="GBUtils">
6877
<HintPath>..\Libs\GBUtils.dll</HintPath>
6978
</Reference>
79+
<Reference Include="HtmlAgilityPack, Version=1.4.9.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
80+
<HintPath>..\packages\HtmlAgilityPack.1.4.9\lib\Net45\HtmlAgilityPack.dll</HintPath>
81+
<Private>True</Private>
82+
</Reference>
7083
<Reference Include="ICSharpCode.SharpZipLib">
7184
<HintPath>..\Libs\ICSharpCode.SharpZipLib.dll</HintPath>
7285
</Reference>
@@ -193,6 +206,9 @@
193206
<Compile Include="Global.asax.cs">
194207
<DependentUpon>Global.asax</DependentUpon>
195208
</Compile>
209+
<Compile Include="Helpers\BC.cs" />
210+
<Compile Include="Helpers\Converters.cs" />
211+
<Compile Include="Helpers\Validators.cs" />
196212
<Compile Include="Logging\ILogger.cs" />
197213
<Compile Include="Logging\TraceLogger.cs" />
198214
<Compile Include="Models\Author.cs" />
@@ -490,6 +506,7 @@
490506
<Content Include="Scripts\modernizr-2.8.3.js" />
491507
<Content Include="Scripts\respond.js" />
492508
<Content Include="Scripts\respond.min.js" />
509+
<Content Include="Scripts\_bookCollection.js" />
493510
<Content Include="Scripts\_references.js" />
494511
<Content Include="Web.config" />
495512
<Content Include="Web.Debug.config">
@@ -530,6 +547,7 @@
530547
<Content Include="Views\Publishers\Edit.cshtml" />
531548
<Content Include="Views\Publishers\Index.cshtml" />
532549
<Content Include="Views\Home\_CategoryBooks.cshtml" />
550+
<Content Include="Views\Shared\_RelatedBooks.cshtml" />
533551
</ItemGroup>
534552
<ItemGroup>
535553
<Folder Include="App_Data\" />

BookCollection/Controllers/AuthorsController.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ public ActionResult Details(int? id)
6666
{
6767
return HttpNotFound();
6868
}
69+
else
70+
{
71+
author.Books = db.Books.Where(b => b.AuthorID == author.AuthorID).ToList();
72+
}
6973
return View(author);
7074
}
7175

BookCollection/Controllers/CategoriesController.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ public ActionResult Details(int? id)
6565
if (category == null)
6666
{
6767
return HttpNotFound();
68+
}else
69+
{
70+
category.Books = db.Books.Where(b => b.CategoryID == category.CategoryID).ToList();
6871
}
6972
return View(category);
7073
}

BookCollection/Controllers/HomeController.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,22 @@ group books by books.Category.Title into catGroup
3333
CategoryName = catGroup.Key,
3434
BookCount = catGroup.Count()
3535
};
36-
stats.CatGroupStats = grp.OrderByDescending(cg => cg.BookCount).ThenBy(cg => cg.CategoryName).ToList();
37-
stats.Categories = stats.CatGroupStats.Count();
38-
39-
// SQL version of the above LINQ code.
36+
37+
stats.CategoryGroupStats = grp.OrderByDescending(cg => cg.BookCount).ThenBy(cg => cg.CategoryName).ToList();
38+
stats.Categories = stats.CategoryGroupStats.Count();
39+
40+
IQueryable<CategoryGroup> grpLang = from books in db.Books
41+
group books by books.Language into catGroup
42+
select new CategoryGroup()
43+
{
44+
CategoryName = catGroup.Key.ToString(),
45+
BookCount = catGroup.Count()
46+
};
47+
48+
stats.LanguageGroupStats = grpLang.OrderByDescending(cg => cg.BookCount).ThenBy(cg => cg.CategoryName).ToList();
49+
stats.Languages = stats.LanguageGroupStats.Count();
50+
51+
// SQL version of the above LINQ code.
4052
//string query = "SELECT EnrollmentDate, COUNT(*) AS StudentCount "
4153
// + "FROM Person "
4254
// + "WHERE Discriminator = 'Student' "

BookCollection/Controllers/PublishersController.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ public ActionResult Details(int? id)
6666
{
6767
return HttpNotFound();
6868
}
69+
else
70+
{
71+
publisher.Books = db.Books.Where(b => b.PublisherID == publisher.PublisherID).ToList();
72+
}
6973
return View(publisher);
7074
}
7175

BookCollection/Controllers/SubjectsController.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ public ActionResult Details(int? id)
6565
if (subject == null)
6666
{
6767
return HttpNotFound();
68+
}else
69+
{
70+
subject.Books = db.Books.Where(b => b.MainSubjectID == subject.SubjectID).ToList();
6871
}
6972
return View(subject);
7073
}

0 commit comments

Comments
 (0)