Permalink
Browse files

Step 6

  • Loading branch information...
1 parent 7105126 commit 3e40257525972fc4a8c1907c723ab24992e1f0c3 @AlexManduley committed Mar 18, 2013
Binary file not shown.
Binary file not shown.
@@ -111,6 +111,30 @@ public ActionResult DeleteConfirmed(int id)
return RedirectToAction("Index");
}
+ //
+ // Search Action
+
+ public ActionResult SearchIndex(string searchString)
+ {
+ //string searchString = id;
+ var movies = from m in db.Movies
+ select m;
+
+ if (!String.IsNullOrEmpty(searchString))
+ {
+ movies = movies.Where(s => s.Title.Contains(searchString));
+ }
+
+ return View(movies);
+
+ }
+
+ [HttpPost]
+ public string SearchIndex(FormCollection fc, string searchString)
+ {
+ return "<h3> From [HttpPost]SearchIndex: " + searchString + "</h3>";
+ }
+
protected override void Dispose(bool disposing)
{
db.Dispose();
View
@@ -243,6 +243,7 @@
<Content Include="Views\Movies\Create.cshtml" />
<Content Include="Views\Movies\Edit.cshtml" />
<Content Include="Views\Movies\Delete.cshtml" />
+ <Content Include="Views\Movies\SearchIndex.cshtml" />
<None Include="_bin_deployableAssemblies\x86\sqlcese40.dll" />
<None Include="_bin_deployableAssemblies\x86\sqlceqp40.dll" />
<None Include="_bin_deployableAssemblies\x86\sqlceme40.dll" />
@@ -274,7 +275,9 @@
<Content Include="Scripts\knockout-2.1.0.debug.js" />
<Content Include="Scripts\knockout-2.1.0.js" />
<Content Include="Scripts\modernizr-2.5.3.js" />
- <Content Include="Web.config" />
+ <Content Include="Web.config">
+ <SubType>Designer</SubType>
+ </Content>
<Content Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
</Content>
@@ -0,0 +1,56 @@
+@model IEnumerable<MvcMovie.Models.Movie>
+
+@{
+ ViewBag.Title = "SearchIndex";
+}
+
+<h2>SearchIndex</h2>
+
+<p>
+ @Html.ActionLink("Create New", "Create")
+
+ @using (Html.BeginForm("SearchIndex","Movies",FormMethod.Get)){
+ <p> Title: @Html.TextBox("SearchString")
+ <input type="submit" value="Filter" /></p>
+ }
+</p>
+<table>
+ <tr>
+ <th>
+ @Html.DisplayNameFor(model => model.Title)
+ </th>
+ <th>
+ @Html.DisplayNameFor(model => model.ReleaseDate)
+ </th>
+ <th>
+ @Html.DisplayNameFor(model => model.Genre)
+ </th>
+ <th>
+ @Html.DisplayNameFor(model => model.Price)
+ </th>
+ <th></th>
+ </tr>
+
+@foreach (var item in Model) {
+ <tr>
+ <td>
+ @Html.DisplayFor(modelItem => item.Title)
+ </td>
+ <td>
+ @Html.DisplayFor(modelItem => item.ReleaseDate)
+ </td>
+ <td>
+ @Html.DisplayFor(modelItem => item.Genre)
+ </td>
+ <td>
+ @Html.DisplayFor(modelItem => item.Price)
+ </td>
+ <td>
+ @Html.ActionLink("Edit", "Edit", new { id=item.ID }) |
+ @Html.ActionLink("Details", "Details", new { id=item.ID }) |
+ @Html.ActionLink("Delete", "Delete", new { id=item.ID })
+ </td>
+ </tr>
+}
+
+</table>

0 comments on commit 3e40257

Please sign in to comment.