Permalink
Browse files

Completed the test app.

  • Loading branch information...
1 parent 8f9b8d6 commit 83927a87d2b0a733a8c9da1d5b819101e5298888 @elishnevsky committed Nov 8, 2012
Showing with 625 additions and 179 deletions.
  1. +1 −1 .gitignore
  2. +40 −0 test/Ext.Direct.Mvc4Test/Controllers/BasicController.cs
  3. +42 −0 test/Ext.Direct.Mvc4Test/Controllers/ContactsController.cs
  4. +27 −0 test/Ext.Direct.Mvc4Test/Controllers/FilesController.cs
  5. +0 −19 test/Ext.Direct.Mvc4Test/Controllers/MoviesController.cs
  6. +0 −16 test/Ext.Direct.Mvc4Test/Controllers/TestController.cs
  7. +35 −0 test/Ext.Direct.Mvc4Test/Controllers/TreeController.cs
  8. +15 −8 test/Ext.Direct.Mvc4Test/Ext.Direct.Mvc4Test.csproj
  9. +1 −1 test/Ext.Direct.Mvc4Test/Global.asax.cs
  10. +14 −0 test/Ext.Direct.Mvc4Test/Models/Contact.cs
  11. +2 −4 test/Ext.Direct.Mvc4Test/Models/{MovieDbContext.cs → ContactsContext.cs}
  12. +82 −0 test/Ext.Direct.Mvc4Test/Models/ContactsInitializer.cs
  13. +0 −13 test/Ext.Direct.Mvc4Test/Models/Genre.cs
  14. +0 −14 test/Ext.Direct.Mvc4Test/Models/Movie.cs
  15. +0 −45 test/Ext.Direct.Mvc4Test/Models/MovieDbInitializer.cs
  16. +0 −12 test/Ext.Direct.Mvc4Test/Models/MovieGenre.cs
  17. +41 −2 test/Ext.Direct.Mvc4Test/Views/Home/Index.cshtml
  18. +1 −1 test/Ext.Direct.Mvc4Test/Web.config
  19. +0 −43 test/Ext.Direct.Mvc4Test/app/app.js
  20. +24 −0 test/Ext.Direct.Mvc4Test/resources/css/main.css
  21. +12 −0 test/Ext.Direct.Mvc4Test/scripts/Contact.js
  22. +65 −0 test/Ext.Direct.Mvc4Test/scripts/ContactForm.js
  23. +40 −0 test/Ext.Direct.Mvc4Test/scripts/ContactsGrid.js
  24. +44 −0 test/Ext.Direct.Mvc4Test/scripts/FileUploadForm.js
  25. +109 −0 test/Ext.Direct.Mvc4Test/scripts/Main.js
  26. +30 −0 test/Ext.Direct.Mvc4Test/scripts/Tree.js
View
@@ -90,4 +90,4 @@ Desktop.ini
$RECYCLE.BIN/
## Project specific ignores
-Movies.sdf
+Contacts.sdf
@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using System.Web.Mvc;
+using Ext.Direct.Mvc;
+using Ext.Direct.Mvc4Test.Models;
+
+namespace Ext.Direct.Mvc4Test.Controllers {
+
+ public class BasicController : DirectController {
+
+ public ActionResult Echo(string text, DateTime date, Contact contact) {
+ return Json(new {
+ text,
+ date,
+ contact
+ });
+ }
+
+ [NamedArguments]
+ public ActionResult EchoNamedArgs(string text, DateTime date, Contact contact) {
+ return Json(new {
+ text,
+ date,
+ contact
+ });
+ }
+
+ public ActionResult TestException() {
+ var e = new DirectException("Oh no! Something bad happened!!!");
+ e.Data.Add("stringInfo", "Additional string information.");
+ e.Data["intInfo"] = -903;
+ e.Data["dateTimeInfo"] = DateTime.Now;
+ throw e;
+
+ return Json("This line is never reached.");
+ }
+ }
+}
@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Web;
+using System.Web.Mvc;
+using Ext.Direct.Mvc;
+using Ext.Direct.Mvc4Test.Models;
+
+namespace Ext.Direct.Mvc4Test.Controllers {
+ public class ContactsController : DirectController {
+
+ private readonly ContactsContext db = new ContactsContext();
+
+ public ActionResult GetList(int start, int limit) {
+ var total = db.Contacts.Count();
+ var contacts = db.Contacts.OrderBy(c => c.FirstName).ThenBy(c => c.LastName).Skip(start).Take(limit).ToList();
+ return Json(new {
+ total = total,
+ data = contacts
+ });
+ }
+
+ public ActionResult Get(int id) {
+ var contact = db.Contacts.Single(c => c.ID == id);
+ return Json(new {
+ success = true,
+ data = contact
+ });
+ }
+
+ [FormHandler]
+ public ActionResult Update(Contact contact) {
+ db.Entry(contact).State = EntityState.Modified;
+ db.SaveChanges();
+ return Json(new {
+ success = true,
+ data = contact
+ });
+ }
+ }
+}
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Web;
+using System.Web.Mvc;
+using Ext.Direct.Mvc;
+
+namespace Ext.Direct.Mvc4Test.Controllers {
+ public class FilesController : DirectController {
+ [FormHandler]
+ public ActionResult Upload() {
+ var files = Request.Files;
+
+ foreach (string file in files) {
+ HttpPostedFileBase hpf = files[file];
+ if (hpf.ContentLength == 0)
+ continue;
+ string folderPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Uploaded Files");
+ string savedFileName = Path.Combine(folderPath, Path.GetFileName(hpf.FileName));
+ hpf.SaveAs(savedFileName);
+ }
+
+ return Json(new { success = true });
+ }
+ }
+}
@@ -1,19 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Web;
-using System.Web.Mvc;
-using Ext.Direct.Mvc;
-using Ext.Direct.Mvc4Test.Models;
-
-namespace Ext.Direct.Mvc4Test.Controllers {
- public class MoviesController : DirectController {
-
- private readonly MovieDbContext db = new MovieDbContext();
-
- public ActionResult GetAll() {
- var movies = db.Movies;
- return Json(movies);
- }
- }
-}
@@ -1,16 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Web;
-using System.Web.Mvc;
-using Ext.Direct.Mvc;
-
-namespace Ext.Direct.Mvc4Test.Controllers {
-
- public class TestController : DirectController {
-
- public ActionResult EchoDateTime(DateTime dt) {
- return Json(dt);
- }
- }
-}
@@ -0,0 +1,35 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using System.Web.Mvc;
+using Ext.Direct.Mvc;
+
+namespace Ext.Direct.Mvc4Test.Controllers {
+ public class TreeController : DirectController {
+
+ public ActionResult Load(string nodeId) {
+ var array = new ArrayList();
+ if (nodeId == "root") {
+ for (int i = 0; i <= 5; i++) {
+ array.Add(new {
+ id = "n" + i,
+ text = "Node " + i,
+ leaf = false
+ });
+ }
+ } else if (nodeId.Length == 2) {
+ var num = nodeId.Substring(1);
+ for (int i = 0; i <= 5; i++) {
+ array.Add(new {
+ id = nodeId + i,
+ text = "Node " + num + i,
+ leaf = true
+ });
+ }
+ }
+ return Json(array.ToArray());
+ }
+ }
+}
@@ -111,25 +111,31 @@
</Reference>
</ItemGroup>
<ItemGroup>
+ <Compile Include="Controllers\FilesController.cs" />
<Compile Include="Controllers\HomeController.cs" />
- <Compile Include="Controllers\MoviesController.cs" />
- <Compile Include="Controllers\TestController.cs" />
+ <Compile Include="Controllers\ContactsController.cs" />
+ <Compile Include="Controllers\BasicController.cs" />
+ <Compile Include="Controllers\TreeController.cs" />
<Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon>
</Compile>
- <Compile Include="Models\Genre.cs" />
- <Compile Include="Models\Movie.cs" />
- <Compile Include="Models\MovieDbContext.cs" />
- <Compile Include="Models\MovieDbInitializer.cs" />
- <Compile Include="Models\MovieGenre.cs" />
+ <Compile Include="Models\Contact.cs" />
+ <Compile Include="Models\ContactsContext.cs" />
+ <Compile Include="Models\ContactsInitializer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="App_Start\FilterConfig.cs" />
<Compile Include="App_Start\RouteConfig.cs" />
<Compile Include="App_Start\WebApiConfig.cs" />
- <Content Include="app\app.js" />
+ <Content Include="scripts\ContactForm.js" />
+ <Content Include="scripts\ContactsGrid.js" />
+ <Content Include="resources\css\main.css" />
+ <Content Include="scripts\FileUploadForm.js" />
+ <Content Include="scripts\Main.js" />
+ <Content Include="scripts\Contact.js" />
<Content Include="Global.asax" />
+ <Content Include="scripts\Tree.js" />
<Content Include="Web.config" />
<Content Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
@@ -141,6 +147,7 @@
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />
+ <Folder Include="Uploaded Files\" />
</ItemGroup>
<ItemGroup>
<Content Include="packages.config" />
@@ -20,7 +20,7 @@ public class MvcApplication : System.Web.HttpApplication {
RouteConfig.RegisterRoutes(RouteTable.Routes);
// Initialize the database with sample data
- Database.SetInitializer<MovieDbContext>(new MovieDbInitializer());
+ Database.SetInitializer<ContactsContext>(new ContactsInitializer());
}
}
}
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace Ext.Direct.Mvc4Test.Models {
+ public class Contact {
+ public int ID { get; set; }
+ public string FirstName { get; set; }
+ public string LastName { get; set; }
+ public DateTime BirthDate { get; set; }
+ public bool Employed { get; set; }
+ }
+}
@@ -6,10 +6,8 @@
using System.Web;
namespace Ext.Direct.Mvc4Test.Models {
- public class MovieDbContext : DbContext {
- public DbSet<Movie> Movies { get; set; }
- public DbSet<Genre> Genres { get; set; }
- public DbSet<MovieGenre> MovieGenres { get; set; }
+ public class ContactsContext : DbContext {
+ public DbSet<Contact> Contacts { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder) {
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
@@ -0,0 +1,82 @@
+using System;
+using System.Collections.Generic;
+using System.Data.Entity;
+using System.Linq;
+using System.Web;
+
+namespace Ext.Direct.Mvc4Test.Models {
+ public class ContactsInitializer : DropCreateDatabaseAlways<ContactsContext> {
+ protected override void Seed(ContactsContext context) {
+ var contacts = new List<Contact> {
+ new Contact {FirstName = "Carson", LastName = "Alexander", BirthDate = DateTime.Parse("1976-09-01"), Employed = false},
+ new Contact {FirstName = "Meredith", LastName = "Alonso", BirthDate = DateTime.Parse("1980-02-15"), Employed = false},
+ new Contact {FirstName = "Arturo", LastName = "Anand", BirthDate = DateTime.Parse("1969-05-24"), Employed = false},
+ new Contact {FirstName = "Gytis", LastName = "Barzdukas", BirthDate = DateTime.Parse("1973-09-20"), Employed = false},
+ new Contact {FirstName = "Yan", LastName = "Li", BirthDate = DateTime.Parse("1975-11-01"), Employed = false},
+ new Contact {FirstName = "Peggy", LastName = "Justice", BirthDate = DateTime.Parse("1964-01-14"), Employed = false},
+ new Contact {FirstName = "Laura", LastName = "Norman", BirthDate = DateTime.Parse("2001-08-03"), Employed = false},
+ new Contact {FirstName = "Nino", LastName = "Olivetto", BirthDate = DateTime.Parse("1984-03-17"), Employed = false},
+ new Contact {FirstName = "Julio", LastName = "Benesh", BirthDate = DateTime.Parse("1972-11-23"), Employed = true},
+ new Contact {FirstName = "Julio", LastName = "Minich", BirthDate = DateTime.Parse("1972-10-29"), Employed = true},
+ new Contact {FirstName = "Tania", LastName = "Ricco", BirthDate = DateTime.Parse("1991-09-24"), Employed = true},
+ new Contact {FirstName = "Odessa", LastName = "Steuck", BirthDate = DateTime.Parse("1986-06-10"), Employed = true},
+ new Contact {FirstName = "Nelson", LastName = "Raber", BirthDate = DateTime.Parse("1982-08-09"), Employed = false},
+ new Contact {FirstName = "Tyrone", LastName = "Scannell", BirthDate = DateTime.Parse("1987-11-29"), Employed = true},
+ new Contact {FirstName = "Allan", LastName = "Disbrow", BirthDate = DateTime.Parse("1991-08-08"), Employed = true},
+ new Contact {FirstName = "Cody", LastName = "Herrell", BirthDate = DateTime.Parse("1983-11-05"), Employed = true},
+ new Contact {FirstName = "Julio", LastName = "Burgoyne", BirthDate = DateTime.Parse("1976-01-20"), Employed = false},
+ new Contact {FirstName = "Jessie", LastName = "Boedeker", BirthDate = DateTime.Parse("1992-08-14"), Employed = true},
+ new Contact {FirstName = "Allan", LastName = "Leyendecker", BirthDate = DateTime.Parse("1971-05-16"), Employed = true},
+ new Contact {FirstName = "Javier", LastName = "Lockley", BirthDate = DateTime.Parse("1973-02-20"), Employed = true},
+ new Contact {FirstName = "Guy", LastName = "Reasor", BirthDate = DateTime.Parse("1987-04-01"), Employed = true},
+ new Contact {FirstName = "Jamie", LastName = "Brummer", BirthDate = DateTime.Parse("1986-04-11"), Employed = true},
+ new Contact {FirstName = "Jessie", LastName = "Casa", BirthDate = DateTime.Parse("1992-11-16"), Employed = true},
+ new Contact {FirstName = "Marcie", LastName = "Ricca", BirthDate = DateTime.Parse("1985-10-28"), Employed = true},
+ new Contact {FirstName = "Gay", LastName = "Lamoureaux", BirthDate = DateTime.Parse("1976-06-02"), Employed = true},
+ new Contact {FirstName = "Althea", LastName = "Sturtz", BirthDate = DateTime.Parse("1993-11-22"), Employed = false},
+ new Contact {FirstName = "Kenya", LastName = "Morocco", BirthDate = DateTime.Parse("1974-11-30"), Employed = true},
+ new Contact {FirstName = "Rae", LastName = "Pasquariello", BirthDate = DateTime.Parse("1986-05-30"), Employed = true},
+ new Contact {FirstName = "Ted", LastName = "Abundis", BirthDate = DateTime.Parse("1989-01-26"), Employed = false},
+ new Contact {FirstName = "Jessie", LastName = "Schacherer", BirthDate = DateTime.Parse("1970-07-13"), Employed = true},
+ new Contact {FirstName = "Jamie", LastName = "Gleaves", BirthDate = DateTime.Parse("1994-12-31"), Employed = true},
+ new Contact {FirstName = "Hillary", LastName = "Spiva", BirthDate = DateTime.Parse("1979-12-09"), Employed = true},
+ new Contact {FirstName = "Elinor", LastName = "Rockefeller", BirthDate = DateTime.Parse("1994-01-28"), Employed = true},
+ new Contact {FirstName = "Dona", LastName = "Clauss", BirthDate = DateTime.Parse("1992-02-07"), Employed = true},
+ new Contact {FirstName = "Ashlee", LastName = "Kennerly", BirthDate = DateTime.Parse("1989-03-13"), Employed = false},
+ new Contact {FirstName = "Alana", LastName = "Wiersma", BirthDate = DateTime.Parse("1973-09-17"), Employed = true},
+ new Contact {FirstName = "Kelly", LastName = "Holdman", BirthDate = DateTime.Parse("1982-06-11"), Employed = true},
+ new Contact {FirstName = "Mathew", LastName = "Lofthouse", BirthDate = DateTime.Parse("1980-03-25"), Employed = true},
+ new Contact {FirstName = "Dona", LastName = "Tatman", BirthDate = DateTime.Parse("1983-11-12"), Employed = false},
+ new Contact {FirstName = "Clayton", LastName = "Clear", BirthDate = DateTime.Parse("1977-01-12"), Employed = true},
+ new Contact {FirstName = "Rosalinda", LastName = "Urman", BirthDate = DateTime.Parse("1980-04-25"), Employed = true},
+ new Contact {FirstName = "Cody", LastName = "Sayler", BirthDate = DateTime.Parse("1980-10-14"), Employed = true},
+ new Contact {FirstName = "Odessa", LastName = "Averitt", BirthDate = DateTime.Parse("1990-01-17"), Employed = true},
+ new Contact {FirstName = "Ted", LastName = "Poage", BirthDate = DateTime.Parse("1987-09-23"), Employed = true},
+ new Contact {FirstName = "Penelope", LastName = "Gayer", BirthDate = DateTime.Parse("1987-01-12"), Employed = false},
+ new Contact {FirstName = "Katy", LastName = "Bluford", BirthDate = DateTime.Parse("1971-05-17"), Employed = true},
+ new Contact {FirstName = "Kelly", LastName = "Mchargue", BirthDate = DateTime.Parse("1994-11-19"), Employed = true},
+ new Contact {FirstName = "Kathrine", LastName = "Gustavson", BirthDate = DateTime.Parse("1987-06-03"), Employed = true},
+ new Contact {FirstName = "Kelly", LastName = "Hartson", BirthDate = DateTime.Parse("1983-02-20"), Employed = true},
+ new Contact {FirstName = "Carlene", LastName = "Summitt", BirthDate = DateTime.Parse("1976-06-23"), Employed = false},
+ new Contact {FirstName = "Kathrine", LastName = "Vrabel", BirthDate = DateTime.Parse("1978-12-08"), Employed = false},
+ new Contact {FirstName = "Roxie", LastName = "Mcconn", BirthDate = DateTime.Parse("1976-06-22"), Employed = true},
+ new Contact {FirstName = "Margery", LastName = "Pullman", BirthDate = DateTime.Parse("1982-03-13"), Employed = true},
+ new Contact {FirstName = "Avis", LastName = "Bueche", BirthDate = DateTime.Parse("1984-12-05"), Employed = true},
+ new Contact {FirstName = "Esmeralda", LastName = "Katzer", BirthDate = DateTime.Parse("1983-05-27"), Employed = true},
+ new Contact {FirstName = "Tania", LastName = "Belmonte", BirthDate = DateTime.Parse("1978-04-01"), Employed = false},
+ new Contact {FirstName = "Malinda", LastName = "Kwak", BirthDate = DateTime.Parse("1979-09-30"), Employed = true},
+ new Contact {FirstName = "Tanisha", LastName = "Jobin", BirthDate = DateTime.Parse("1972-05-06"), Employed = false},
+ new Contact {FirstName = "Kelly", LastName = "Dziedzic", BirthDate = DateTime.Parse("1982-01-25"), Employed = true},
+ new Contact {FirstName = "Darren", LastName = "Devalle", BirthDate = DateTime.Parse("1987-01-22"), Employed = true},
+ new Contact {FirstName = "Julio", LastName = "Buchannon", BirthDate = DateTime.Parse("1987-12-04"), Employed = true},
+ new Contact {FirstName = "Darren", LastName = "Schreier", BirthDate = DateTime.Parse("1994-05-16"), Employed = false},
+ new Contact {FirstName = "Jamie", LastName = "Pollman", BirthDate = DateTime.Parse("1996-01-06"), Employed = true},
+ new Contact {FirstName = "Karina", LastName = "Pompey", BirthDate = DateTime.Parse("1992-06-10"), Employed = true},
+ new Contact {FirstName = "Hugh", LastName = "Snover", BirthDate = DateTime.Parse("1978-08-14"), Employed = true},
+ new Contact {FirstName = "Zebra", LastName = "Evilias", BirthDate = DateTime.Parse("1971-09-10"), Employed = true}
+ };
+ contacts.ForEach(c => context.Contacts.Add(c));
+ context.SaveChanges();
+ }
+ }
+}
@@ -1,13 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Web;
-
-namespace Ext.Direct.Mvc4Test.Models {
- public class Genre {
- public int ID { get; set; }
- public string Name { get; set; }
-
- public virtual ICollection<MovieGenre> MovieGenres { get; set; }
- }
-}
@@ -1,14 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Web;
-
-namespace Ext.Direct.Mvc4Test.Models {
- public class Movie {
- public int ID { get; set; }
- public string Title { get; set; }
- public DateTime ReleaseDate { get; set; }
-
- public virtual ICollection<MovieGenre> MovieGenres { get; set; }
- }
-}
Oops, something went wrong.

0 comments on commit 83927a8

Please sign in to comment.