-1

I would like to learn AngularJs. I'm familar with ASP.NET MVC. I'm going to write some web app and I want to use AngularJs in client side and ASP.NET MVC 5 in server side.

I project solution:

  • Project Web - client side ( AngularJs)
  • Core (DAL, repositories, business layer) (C#)
  • Test

Is is good architecture ? What do you think about it ?

mskuratowski
  • 4,014
  • 15
  • 58
  • 109

1 Answers1

1

I would use:

  • ASP.NET MVC for url routing and page rendering (plus localization if you need it).
  • Angular JS for client side development.
  • ASP.NET WebApi for Ajax requests.

Business and Data Access Layers will be developed in external projects, of course in C#.

My personal tools for testing are NUnit, NSubstitute (mocking library), FluentAssertions and AutoFixture for text data generation.

Think also about using an IoC container and implement your project using dependency injection of components. I'm personally a fan of Autofac, but there are other options that you can consider.

I would also suggest you to give a look at NancyFx, a lightweight framework that can be used in place of MVC and WebApi. More information here: Benefits of using NancyFx?

To summarize the solution layout:

  • One project will contain MVC and Web API controllers and angular script file
  • Another project will contain the Business Layer (I prefer to call it Domain Layer)
  • Another project will contain the Data Access Layer
  • Each project will have a corresponding test project, following the xUnit conventions.

If you apply Inversion of Control, you can define all comunication interfaces in the domain layer and then make the UI layer and the Data Access Layer reference it.

Community
  • 1
  • 1
Paolo Costa
  • 1,989
  • 1
  • 12
  • 15
  • To sum up, you suggest: ASP.NET MVC, AngularJs, WebApi - is it one project right ? What do you think about xUnit ? – mskuratowski May 10 '15 at 12:44
  • Yes, the MVC application will be very simple, only controllers (one if you have a single page application, more if you have more single page applications which is normal) and will be responsible for routing and rendering (you will probably don't define any model inside it). Angular controllers and views will be javascript file defined inside the MVC application. Anyway, The MVC project can contain both the MVC and the API controllers, that will be used by Angular controllers to call server side functions. – Paolo Costa May 10 '15 at 12:46
  • xUnit is fine, but to be honest I never used it. I fell good with nUnit :-) – Paolo Costa May 10 '15 at 12:47
  • And if you plan to use an IoC container (which I strongly suggest) take car to know HOW to use it. I strongly suggest you to start from Mark Seemann's blog (http://blog.ploeh.dk/) and book (http://www.manning.com/seemann/). You will avoid very dangerous mistakes :-) – Paolo Costa May 10 '15 at 12:50
  • Okay, so I'm going to create 3 project in one solution then. Thanks – mskuratowski May 10 '15 at 13:47
  • I was not strictly talking about the solution the layout, so I updated my answer to clarify how I would do it. – Paolo Costa May 10 '15 at 17:15