Skip to content

Commit e63f2c9

Browse files
committed
Added code to Module 2 and Module 3 folders
1 parent 2345038 commit e63f2c9

File tree

180 files changed

+59146
-4
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

180 files changed

+59146
-4
lines changed
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Data;
4+
using System.Data.Entity;
5+
using System.Linq;
6+
using System.Net;
7+
using System.Web;
8+
using System.Web.Mvc;
9+
using MVCMusicStore.Models;
10+
11+
namespace MVCMusicStore.Controllers
12+
{
13+
public class AlbumsController : Controller
14+
{
15+
private StoreContext db = new StoreContext();
16+
17+
// GET: Albums
18+
public ActionResult Index()
19+
{
20+
return View(db.Albums.ToList());
21+
}
22+
23+
// GET: Albums/Details/5
24+
public ActionResult Details(int? id)
25+
{
26+
if (id == null)
27+
{
28+
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
29+
}
30+
Album album = db.Albums.Find(id);
31+
if (album == null)
32+
{
33+
return HttpNotFound();
34+
}
35+
return View(album);
36+
}
37+
38+
// GET: Albums/Create
39+
public ActionResult Create()
40+
{
41+
return View();
42+
}
43+
44+
// POST: Albums/Create
45+
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
46+
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
47+
[HttpPost]
48+
[ValidateAntiForgeryToken]
49+
public ActionResult Create([Bind(Include = "AlbumID,Title")] Album album)
50+
{
51+
if (ModelState.IsValid)
52+
{
53+
db.Albums.Add(album);
54+
db.SaveChanges();
55+
return RedirectToAction("Index");
56+
}
57+
58+
return View(album);
59+
}
60+
61+
// GET: Albums/Edit/5
62+
public ActionResult Edit(int? id)
63+
{
64+
if (id == null)
65+
{
66+
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
67+
}
68+
Album album = db.Albums.Find(id);
69+
if (album == null)
70+
{
71+
return HttpNotFound();
72+
}
73+
return View(album);
74+
}
75+
76+
// POST: Albums/Edit/5
77+
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
78+
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
79+
[HttpPost]
80+
[ValidateAntiForgeryToken]
81+
public ActionResult Edit([Bind(Include = "AlbumID,Title")] Album album)
82+
{
83+
if (ModelState.IsValid)
84+
{
85+
db.Entry(album).State = EntityState.Modified;
86+
db.SaveChanges();
87+
return RedirectToAction("Index");
88+
}
89+
return View(album);
90+
}
91+
92+
// GET: Albums/Delete/5
93+
public ActionResult Delete(int? id)
94+
{
95+
if (id == null)
96+
{
97+
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
98+
}
99+
Album album = db.Albums.Find(id);
100+
if (album == null)
101+
{
102+
return HttpNotFound();
103+
}
104+
return View(album);
105+
}
106+
107+
// POST: Albums/Delete/5
108+
[HttpPost, ActionName("Delete")]
109+
[ValidateAntiForgeryToken]
110+
public ActionResult DeleteConfirmed(int id)
111+
{
112+
Album album = db.Albums.Find(id);
113+
db.Albums.Remove(album);
114+
db.SaveChanges();
115+
return RedirectToAction("Index");
116+
}
117+
118+
protected override void Dispose(bool disposing)
119+
{
120+
if (disposing)
121+
{
122+
db.Dispose();
123+
}
124+
base.Dispose(disposing);
125+
}
126+
}
127+
}

MVCMusicStore/MVCMusicStore/MVCMusicStore.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@
159159
<Compile Include="App_Start\RouteConfig.cs" />
160160
<Compile Include="App_Start\Startup.Auth.cs" />
161161
<Compile Include="Controllers\AccountController.cs" />
162+
<Compile Include="Controllers\AlbumsController.cs" />
162163
<Compile Include="Controllers\HomeController.cs" />
163164
<Compile Include="Controllers\ReviewsController.cs" />
164165
<Compile Include="Global.asax.cs">

MVCMusicStore/MVCMusicStore/Views/Albums/Create.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
ViewBag.Title = "Create";
55
}
66

7-
<h2>Create</h2>
7+
<h2>Create a new wonderful album!</h2>
88

99

1010
@using (Html.BeginForm())

MVCMusicStore/MVCMusicStore/Views/Reviews/Create.cshtml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
ViewBag.Title = "Create";
55
}
66

7-
<h2>Create</h2>
8-
7+
<h2>Create a new album here folks!</h2>
98

109
@using (Html.BeginForm())
1110
{
1211
@Html.AntiForgeryToken()
1312

13+
14+
1415
<div class="form-horizontal">
1516
<h4>Review</h4>
1617
<hr />

Module 1 - Basics of MVC/readme.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Source code for the Introduction to ASP.NET MVC free training course on June 23, 2014 (http://www.microsoftvirtualacademy.com/liveevents/introduction-to-asp-net-mvc)
1+
(no code for this session)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<!--
3+
Note: Add entries to the App.config file for configuration settings
4+
that apply only to the Test project.
5+
-->
6+
<configuration>
7+
<appSettings>
8+
9+
</appSettings>
10+
11+
<connectionStrings>
12+
13+
</connectionStrings>
14+
</configuration>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Web.Mvc;
6+
using Microsoft.VisualStudio.TestTools.UnitTesting;
7+
using MVCMusicStore;
8+
using MVCMusicStore.Controllers;
9+
10+
namespace MVCMusicStore.Tests.Controllers
11+
{
12+
[TestClass]
13+
public class HomeControllerTest
14+
{
15+
[TestMethod]
16+
public void Index()
17+
{
18+
// Arrange
19+
HomeController controller = new HomeController();
20+
21+
// Act
22+
ViewResult result = controller.Index() as ViewResult;
23+
24+
// Assert
25+
Assert.IsNotNull(result);
26+
}
27+
28+
[TestMethod]
29+
public void About()
30+
{
31+
// Arrange
32+
HomeController controller = new HomeController();
33+
34+
// Act
35+
ViewResult result = controller.About() as ViewResult;
36+
37+
// Assert
38+
Assert.AreEqual("Your application description page.", result.ViewBag.Message);
39+
}
40+
41+
[TestMethod]
42+
public void Contact()
43+
{
44+
// Arrange
45+
HomeController controller = new HomeController();
46+
47+
// Act
48+
ViewResult result = controller.Contact() as ViewResult;
49+
50+
// Assert
51+
Assert.IsNotNull(result);
52+
}
53+
}
54+
}
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProductVersion>
7+
</ProductVersion>
8+
<SchemaVersion>2.0</SchemaVersion>
9+
<ProjectGuid>{80CD1024-7400-47A8-8F3D-46DA1DDA5DBA}</ProjectGuid>
10+
<OutputType>Library</OutputType>
11+
<AppDesignerFolder>Properties</AppDesignerFolder>
12+
<RootNamespace>MVCMusicStore.Tests</RootNamespace>
13+
<AssemblyName>MVCMusicStore.Tests</AssemblyName>
14+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
15+
<FileAlignment>512</FileAlignment>
16+
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
17+
</PropertyGroup>
18+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
19+
<DebugSymbols>true</DebugSymbols>
20+
<DebugType>full</DebugType>
21+
<Optimize>false</Optimize>
22+
<OutputPath>bin\Debug\</OutputPath>
23+
<DefineConstants>DEBUG;TRACE</DefineConstants>
24+
<ErrorReport>prompt</ErrorReport>
25+
<WarningLevel>4</WarningLevel>
26+
</PropertyGroup>
27+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<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="System" />
39+
<Reference Include="System.ComponentModel.DataAnnotations" />
40+
<Reference Include="System.Configuration" />
41+
<Reference Include="System.Core" />
42+
<Reference Include="System.Data" />
43+
<Reference Include="System.Web" />
44+
<Reference Include="System.Web.ApplicationServices" />
45+
<Reference Include="System.Web.Extensions" />
46+
<Reference Include="System.Web.Abstractions" />
47+
<Reference Include="System.Web.Routing" />
48+
<Reference Include="System.Xml" />
49+
<Reference Include="System.Xml.Linq" />
50+
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
51+
<Private>True</Private>
52+
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
53+
</Reference>
54+
<Reference Include="Newtonsoft.Json">
55+
<HintPath>..\packages\Newtonsoft.Json.5.0.6\lib\net45\Newtonsoft.Json.dll</HintPath>
56+
</Reference>
57+
<Reference Include="System.Net.Http" />
58+
<Reference Include="System.Net.Http.WebRequest" />
59+
<Reference Include="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
60+
<Private>True</Private>
61+
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.1.2\lib\net45\System.Web.Helpers.dll</HintPath>
62+
</Reference>
63+
<Reference Include="System.Web.Mvc, Version=5.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
64+
<Private>True</Private>
65+
<HintPath>..\packages\Microsoft.AspNet.Mvc.5.1.2\lib\net45\System.Web.Mvc.dll</HintPath>
66+
</Reference>
67+
<Reference Include="System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
68+
<Private>True</Private>
69+
<HintPath>..\packages\Microsoft.AspNet.Razor.3.1.2\lib\net45\System.Web.Razor.dll</HintPath>
70+
</Reference>
71+
<Reference Include="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
72+
<Private>True</Private>
73+
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.1.2\lib\net45\System.Web.WebPages.dll</HintPath>
74+
</Reference>
75+
<Reference Include="System.Web.WebPages.Deployment, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
76+
<Private>True</Private>
77+
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.1.2\lib\net45\System.Web.WebPages.Deployment.dll</HintPath>
78+
</Reference>
79+
<Reference Include="System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
80+
<Private>True</Private>
81+
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.1.2\lib\net45\System.Web.WebPages.Razor.dll</HintPath>
82+
</Reference>
83+
</ItemGroup>
84+
<ItemGroup>
85+
<Compile Include="Properties\AssemblyInfo.cs" />
86+
<Compile Include="Controllers\HomeControllerTest.cs" />
87+
</ItemGroup>
88+
<ItemGroup>
89+
<Content Include="App.config" />
90+
</ItemGroup>
91+
<ItemGroup>
92+
<None Include="packages.config" />
93+
</ItemGroup>
94+
<ItemGroup>
95+
<ProjectReference Include="..\MVCMusicStore\MVCMusicStore.csproj">
96+
<Project>{05F5C509-CC1B-449F-AB64-DD38C40B91A3}</Project>
97+
<Name>MVCMusicStore</Name>
98+
</ProjectReference>
99+
</ItemGroup>
100+
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
101+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
102+
Other similar extension points exist, see Microsoft.Common.targets.
103+
<Target Name="BeforeBuild">
104+
</Target>
105+
<Target Name="AfterBuild">
106+
</Target>
107+
-->
108+
</Project>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("MVCMusicStore.Tests")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("MVCMusicStore.Tests")]
13+
[assembly: AssemblyCopyright("Copyright © 2014")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("3a28286c-31b3-4101-9d6a-f14b1fce46f7")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Revision and Build Numbers
33+
// by using the '*' as shown below:
34+
[assembly: AssemblyVersion("1.0.0.0")]
35+
[assembly: AssemblyFileVersion("1.0.0.0")]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="Microsoft.AspNet.Mvc" version="5.1.2" targetFramework="net45" />
4+
<package id="Microsoft.AspNet.Razor" version="3.1.2" targetFramework="net45" />
5+
<package id="Microsoft.AspNet.WebPages" version="3.1.2" targetFramework="net45" />
6+
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
7+
<package id="Newtonsoft.Json" version="5.0.6" targetFramework="net45" />
8+
</packages>

0 commit comments

Comments
 (0)