I say without playoff success, who care?
Da. Is true. He now 'resting' for playoffs? Law l. Enough Hockey talk, on with the shaw.
My comrade, Ivan Vandermiev, and I have collaborated to construct back end to the SproutCore Todos tutorial from weekee site. Is weekee maintained still? who knows? He and I collaborate to make great effort at making work with the SproutCore while making very smallest effort at typing. I suspecting that he have ladies hands and extra typing make his hands hurt.
Alexei say traditional 'enterprisey' level Microsoft solution would include:
- re-emergence of "Microsoft Bob" from 1995 to be AI project architect
- endless meetings of steering committees to ensure compliance with project goals
- three months of building a code generation engine to produce framework code that needs extensive refactoring to begin working
- zune integration
Zune integration: DA!. law l. Nyet.
I let comrade Vandermiev splain how back end work. He have good english skills.
Ivan sent me email splanation:
-------------------------------------------------------------------------------------------------------------
Comrade Cliftov, I have created the secret back end project you requested. I used 'Code-First Development with .NET 4 Entity Framework' to create and maintain the database schema. Why? Why not?
I have written enough boilerplate SQL to last me a lifetime and writing CRUD code for this secret project will add no value. I let the Entity Framework manage the objects so I don't have to. To access, the data I used ASP.NET MVC3. Why MVC3? Because its better than MVC1 and MVC2. Everything with higher numbers is better, except for weight of that girl in Vegas. Eh Comrade Cliftov?
Code exerpts follow:
Automatically generates the database schema when class is created:
namespace SproutCoreMVC.Models
{
public class Task
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int id { get; set; }
public string description { get; set; }
public int order { get; set; }
public bool isDone { get; set; }
public string guid { get {return "/tasks/" + id;} }
}
public class SCModels : DbContext
{
public DbSet<Task> Tasks { get; set; }
}
public class SCModelsInitializer : DropCreateDatabaseIfModelChanges<SCModels>
{
protected override void Seed(SCModels context)
{
var tasks = new List<Task>
{
new Task {
order = 1,
isDone = false,
description = "Some Description"
}};
tasks.ForEach(d => context.Tasks.Add(d));
context.SaveChanges();
}
}
}This is the REST implementation. Easy da?
namespace SproutCoreMVC.Controllers
{
public class TasksController : Controller
{
SCModels db = new SCModels();
// GET: /tasks
[HttpGet]
[NoCache]
public ActionResult List()
{
return Json(new {content = db.Tasks}, JsonRequestBehavior.AllowGet);
}
//GET: /tasks/id
[HttpGet]
[NoCache]
public JsonResult Get(int id)
{
return Json(db.Tasks.Find(id), JsonRequestBehavior.AllowGet);
}
//PUT: /tasks/id
[HttpPut]
public ActionResult Update(Task task)
{
var taskToUpdate = db.Tasks.Find(task.id);
UpdateModel(taskToUpdate);
db.SaveChanges();
return Json(taskToUpdate);
}
//POST: /tasks
[HttpPost]
public ActionResult Create(Task task)
{
db.Tasks.Add(task);
db.SaveChanges();
//set location and to redirect headers
Response.StatusCode = 201;
Response.RedirectLocation = task.guid;
return new EmptyResult();
}
//DELETE: /tasks/id
[HttpDelete]
public ActionResult Delete(int id)
{
db.Tasks.Remove(db.Tasks.Find(id));
db.SaveChanges();
return new EmptyResult();
}
}
} I left out the routing information. As you can see the integration between SproutCore and asp.net MVC3 and Entity Framework 4 is quite straightforward and painless. I actually only write about 70 lines of code. Is much easier than you half of project.
Sincerely,
Ivan Vandermiev
-------------------------------------------------------------------------------------------------------------
Da, spasiba Ivan. Very good. I may have exagerated my halfs work.
Client is a git clone https://github.com/sproutit/samples-todos.git with change in Buildfile to point proxy to server:
proxy '/tasks', :to => 'http://hahaha.i.has.secretlab.in.kremlin.ru//'
Comments? Questions?




