MVC architecture like BAL, DAL and Presentation with EntityFramework? - c#-4.0

I want to create a project in Asp.Net MVC with C# using Entity Framework with BAL and DAL layers ? There are two module here User and Admin module with custom login feature. Admin can add run time columns in the existing database with add, edit update the records such as any report.
The record display to the users.
If you have any such type of reference article/project (N-tier architecture) let us know please.

When i create MVC projects, i usually follow this structure:
UI Layer - This will be the actual mvc project and will interact with the service layer
Service Layer (BAL) - This will hold all your business logic classes and will interact with the data access layer. This layer will expose services the UI Layer can make use of
Data Access Layer - This will hold all classes related to data access. As you are using entity framework, your DbContext can live here
Entities - This will hold all entities used in your solution

Related

How to add scheduled jobs in domain driven design

Which layer I should add scheduler project in domain driven design architecture?
I am thinking of adding scheduler in Distributed service layer and business login inside application services layer.
Here is the solution design I am thinking of:
Presentation Layer
UI project
Distribute Service Layer
Application API
Scheduler
Application Layer
Application (Application services for Application API and Scheduler logic)
DTO
Domain Entity Model
Project Domain (Domain entities specific to project)
Scheduler Domain (Domain entities specific to scheduler)
Data Persistence
Data Access Project (Repositories)
Data Access Scheduler Domain (Repositories)
Cross Cutting Infra.
Authorization
Logging
Any help is appreciated.
Since now I've implemented this kind of component in the Presentation layer, on the same level as the UI. These components are awaken by cronjobs at regular times then they call Application services in order to send commands to the Aggregates. Then, the Aggregates, if necessary and allowed, perform the changes to the system state.

Creating liferay service builder without configuring any database

Is it possible to create liferay service builder without any configuring any database tables in service.xml file.
Actually purpose here is to create a service layer using liferay service builder. And there is no database interaction directly in this service layer.
Yes, and it's quite simple. While you still need an entity (which provides the name for your service) you can leave this entity definition empty.
This will create the service (local or remote, as configured in the entity) but no model, no persistence and no database table.
One of the situations where this comes in really handy is when you want to add another method to an existing service (which you can't) - you just create a new service with your custom methods and delegate to the original service.
I agree with #Olaf Kock answare in which say that it is possible have an empty model with service builder. Furthermore have an empty entity you can benefit of have the same transactional context of your portal and benefit of cluster managing and benefit of a complete integration with liferay portal.
If you have the same transactional enviroment of the portal you can image of create a service that agregate native liferay service and you get the assurance that the transactional context is the same of the portal.
I hop that this reflection can add value.
Its highly recommended that If you're creating Service.xml then at least one entity should be there. Otherwise no need to add that configuration.
Able to create service builder without real entities.
As provided in the link it is possible to create service builder without entities.
Also discussed more in detail in this forum
Hope it helps some one. Thanks

Azure Mobile Services with existing database + table controller

I have created Azure Mobile Service using Azure portal and selected a existing database.
Now I have few questions:
Whenever I'll run the application, database gets cleared as ClearDatabaseSchemaIfModelChanges has configured for Database Initializer in WebApiConfig. Can I use database first approach for Entity Framework?
My existing database has default schema is dbo but it will create a new schema for all tables same as service name. How to overcome this scenario?
Finally, TableController is tightly bind to a table. But output requires in my case is bit complex as I require data from multiple table using join each other. And I also wants to add some logic before giving return the result.
And a tightly bound table also requires some common columns like CreatedAt, UpdatedAt, Id, Deleted as it inherit from EntityData class. But In my existing tables, columns are not there.
Help me out !!
You can do the following:
1) Create the custom API for your operations (that are not so tightly connected with the HTTP verbs and the table)
2) Manipulate the DB manually - it is just a SQL Azure database that can be managed by SQL Servre Management Studio, Visual Studio or queries.
So, shortly, if you need the flexibility of doing what you need with the database, you can do it, but Mobile Services is a service, so there are some limitations.
Hope that helps. If not, please elaborate the issue.
first, you should be using Azure Mobile Apps instead of Azure Mobile Services.
You can follow what Alexandr has mentioned, or you can stick with using Mobile App by extending your existing tables to add the required columns (especially if you want to do sync).
The TableControllers are just plain WebAPI controllers, you can certainly extend it.
Have a look at this link for a more guided step on how reuse an existing database.

Use remote database for azure mobile service

I have stored my database on a server say abc.xyz.com
I want to use one of database from this server for azure mobile service.
How can I access this database from my mobile service.?
If you're using the .NET backend of your mobile service, you can fairly easily use the external DB - since it uses Entity Framework as the default data access platform, you can use its tools to create the connection to your DB.
First, open the Entity Framework wizard to "Generate Model from Existing Database": right-click the project, select Add --> New Item --> ADO.NET Entity Data Model, and choose one of the options with from an existing DB (either "EF Designer from database" or "Code First from database"). The wizard will create a context class which you can use when implementing your tables.
Notice that you may need to implement some data mapping since to expose data in the TableController<T> classes you need the T parameter to implement the ITableData interface. The post at http://blogs.msdn.com/b/azuremobile/archive/2014/05/27/bring-your-own-database-with-the-net-backend.aspx and the tutorial at http://azure.microsoft.com/en-us/documentation/articles/mobile-services-dotnet-backend-use-existing-sql-database/ have more information on how to implement your scenario.

In Domain Driven Design the factory classes can access to infraestructure?

If necessary, a factory can access elements of the infrastructure to build an object?. In a particular case, I have an object that I need to add email signature that is stored as a parameter in the configuration layer of the application.
In DDD, a Factory is at the same architectural level as a Repository, but for creating new objects instead of loading existing objects. So it can call infrastructure services just like the repository.
There is no one correct answer to this problem. If the factory itself is part of your application layer this should be fine. You can also add an application service that hands the email signature down into your domain when needed.

Resources