Chorn Sokun's Weblog

Conquer inner fear, push it to the limit!

Posts Tagged ‘ASP.NET MVC

Me & the Onion Architecture

leave a comment »

Jump into ASP.NET MVC 2 in Action Chapter 23 which talk about an integration of ASP.NET MVC and NHibernate the author introduce us to the Onion Architecture.

Using this architecture we simply structure our solution like:

  • Core, storing POCO & various Interfaces
  • Infrastructure, talking with underline or external system
  • IntegrationTests, generally speaking this would test Infrastructure functionality
  • UI

Let focus on the Infrastructure because it is the main actor in this architecture; the following role given to this layer

  • Mapping between Core class & Database by talking through NHibernate (I agree)
  • Responsible for injecting NHibernate session into web session with NHibernateModule: IHttpModule (I agree)
  • Contain abstract RepositoryBase<T>: IRepository<T> (I agree)
  • Contain all Interfaces  implmentation hmm ? isn’t it too much for an Infrastructure? what about
    • Core
    • Infrastructure
    • Services
    • IntegrationTests
    • UI

I will do more investigation (Pros, Cons) but love to hear your take on this, if you haven’t read the chapter yet do it now.

Written by Chorn Sokun

July 25, 2010 at 2:35 pm

Posted in Uncategorized

Tagged with ,

MonoRail vs ASP.NET MVC Take #1 HTTP verbs

with 2 comments

Along came ASP.NET MVC although I am not the fan of ASP.NET MVC but it doens’t heard reading ASP.NET free chapter (nerddinner) and I did learn a few tricks, I will try my best to map concept between the two framework now let see

Why differentiate via HTTP verbs? read the book and find out, but here the deal

  • ASP.NET MVC [AcceptVerbs(HttpVerbs.Post)]
  • and [AccessibleThrough(Verb.Post)] in MonoRail
// GET: /Payroll/Delete/2
public void Delete([ARFetch("id"}] Payroll payroll){
   if (payroll == null)
   {
      RenderView("InvalidRequest");
   }
   else
   {
       PropertyBag["payroll"] = payroll;
       RenderView("DeleteConfirm");
   }
}

// POST: /Payroll/Delete/2
[AccessibleThrough(Verb.Post)]
public void Delete([ARFetch("id"}] Payroll payroll, bool confirm){
   if (payroll == null)
   {
      RenderView("InvalidRequest");
   }
   else
   {
      if(confirm){
     ..... // drop the record off the database
     ..... // do whatever you want.
      }
      else
      {
          RedirectToAction("Delete", "id"  + payroll.Id);
      }
   }
}

MonoRail Rock!

Written by Chorn Sokun

March 26, 2009 at 10:17 am

Posted in Castle, MonoRail, Tips & Tricks

Tagged with