I'm trying to create my first Asp.Net application from scratch. Tried to create this post in some of the other forums but I couldn't find a better place.
So, as the title says, I'm having trouble trying to model my application. I'm like an OOP newbie. I'll show my classes first and then I'll write my questions.
Model Layer
public class User
{
private int id;
public int Id { get { return id; } set { id = value; } }
private string login;
public string Login { get { return login; } set { login = value; } }
private string password;
public string Password { get { return password; } set { password = value; } }
}
Data Access Layer
public class BasicDAL
{
private SqlConnection connection;
//>>Returns a new connection to the database
public SqlConnection GetConnection()
{
//>>If connection is active close it before starting a new one
if (connection != null)
if (connecion.State != ConnectionState.Closed)
connection.Close();
connection = new SqlConnection("MyConnectionStringHere");
return connection;
}
}
public class UserDAL : BasicDAL
{
//>>Insert a new user
public void Insert(User user); { /* Insert into DB */ }
//>>Authenticate user login with its password
public void Authenticate(User user); { /* Authentication code here */ }
}
Business Logic Layer
[Code]....
So, model layer is pretty simple. Just a user representation. On the Data Access Layer I have a basic class with a GetConnection method. All DAL classes will extend this one.
My first problem lies on Business Logic Layer. With the above scenario, I've placed the same methods that I placed at the DAL. BLL methods would call DAL. As simple as that but I believe It is not the best way to do it, is it? How can I improve those classes?
Also, I have to "try..catch" blocks. That's because I can't find good places for it. I mean, if I place a try..catch on GetConnection method, for instance, how my ASPX page would get this error? How my ASPX page can tell the difference between "database offline" and "sql syntax error" when executing "userBll.Insert(newUser);".
My problem is mainly placing the exception handlers. I understand I would probably have to change return type of some methods. I didn't change because I believe that will have something with the exception handlers.
Btw, please assume I can't use TableAdapters and stuff like that. I would like to create all layers by myself.
In my application, I'm binding a Collection of Supervisor type, which I'm feeling that it is an additional overhead. Becuase I only want his ID. So binding an object collection to the dropdown which seems no worth.
I have three layers like UI, business and data access in my asp.net web application project. If I pass say a company code from the UI to the business to the data access and I query the company details like company name, address, phone etc from the database using sqlhelper executedataset() which wil return me a dataset. Then how do I pass these company details back to the UI layer. Is it correct to just pass the datatable object to the business and UI.
I am thinking to use entity model as DAL, how should I create the BLL then? What kind of datasourceobject should I use in the asp pages?
I am looking for best practice to use Entity framework 2 in the three layers design. I had experience at dataset with three layers design.
Should I use objectdatasource at the pages for gridviews? My guess is that entitydatasource by passed the BLL which is not good, so the only option left is the objectdatasource.
Could and should my BL object inherit those entity model in the DAL, so I dont need to recreate their object's property?
I have a quick question in regards to testing my validation. I have been looking through a few MVC examples and have noticed the 'Validating with a Service Layer' tutorial which is pretty nice. It discusses how to abstract your code out etc..My question is, that they have validation occuring in the service layer, if errors occur, the error + message then gets added to a model state dictionary.Now i want to test my model to make sure my business rules are being applied to it, but with this approach, for starters, the Validation method is not in the interface. Now, if the validation method was in the interface, during testing you would have to re-implement the validation on the testing side.Am i missing somthing? Where should your validation code go? I feel like it should go in the model, but then i have to track the errors on the model side.
I doubt how to implement the layers FACADE, BLL and DAL, using DTOs specialized .. where:
public class ClassA { private int _Test1; public int Test1 { get { return _Test1; } set { _Test1 = value; } } } public class ClassAB : ClassA { private int _Test2; public int Test2 { get { return _Test2; } set { _Test2 = value; } } } public class ClassAC : ClassA { private int _Test3; public int Test3 { get { return _Test3; } set { _Test3 = value; } } }
In the database, there is the 3 tables, as described above.how do I implement the facade, bll and dal? only one class for 3 DTOs?
It's appreciated if you could share your thought.I have seen a e-commerce website design which have a few layers:Common,DataAccess,BusinessLogic,Operational.In the Common layer,it includes all the classes with only attributes and properties,no methods nor data access codes here.
In the DataAccess layer,there is a class for each action per class in the Common layer.For example,
a class for the Select action of class A of Common layer, a class for the update action of class A of common layer, a class for the Select action of class�B of Common layer, etc... Is this a design I could use for a potential high trafic website?What's the pro and con of this design.
how the WCF, DAO and DTO layers communicate with each other? I would appreciate if someone can specify which layer comes first and then how it interacts with the next layer
While designing (and then implementing) a layered application:
Is it correct to use the same ORM objects accross all layers? (which would go against encapsulation).
Or the presentation, business and data layer should each have their own objects? (which would lead to lots of code repetition).
e.g. (just to illustrate the question): if one uses Linq to SQL in the Data Layer and Visual Studio's O/R designer to generate the ORM objects, are those objects supposed to be used in the Business and Presentation Layers as well.
i.e.: Are the objects associated with the entities that the application handles a crosscutting issue?
We have many instances in our application where we would like to be able to access things like the currently logged in user id in our business domain and data access layer. On log we push this information to the session, so all of our front end code has access to it fairly easily of course. However, we are having huge issues getting at the data in lower layers of our application. We just can't seem to find a way to store a value in the business domain that has global scope just for the user (static classes and properties are of course shared by the application domain, which means all users in the session share just one copy of the object). We have considered passing in the session to our business classes, but then our domain is very tightly coupled to our web application. We want to keep the prospect of a winforms version of the application possible going forward.
I need to auto update application like in wordpress, Application must check if new updates are available, download this updates and install.But I don't know how to install application. Because if some files in bin directory are updated application is restarted.Is it possible to create ASP.NET web application which will be auto updatable?now we have a new technologies, could u please suggest me any kind of soultion for the above problem. here i am enclosing my email idsunnyb4uu@hotmail.com
I need to develop an application, which will get records (orders) from one application and process them. The updates to this records (order updates) will be sent back to the source application for end customer reference. I'm planning to achieve this data synchronization at the database level using triggers and stored procedures to insert database between the 2 databases.
But, the issue is I have to deploy this application in 3 different customer sites and I have to change the database names (cannot use the same database name) in each deployment manually. Because of this deployment issue, I was thinking of handling this within the asp.net application where I can store the db name in the database and then build the query within the application, but I dont want to do it as building queries like that doesnt look very professional.
I m sure this question has been asked before. I have a web application hosted underhttp://localhost/abc. which is mapped to c:inetputwwwrootabc folder. I have APP_Code, App_LocalResources, BIN and other folders under abc folder. Everything is great. Now I want to create another application or sub application http://localhost/def. Both abc and def apps need to use some common classes and resources. Whats the best way to do it. I dont need to create a separate application for def. All i want is the url http://localhost/def.
I'm starting to plan an architecture for a big web application, and I wanted to get suggestions and/or recommendations on where to begin and which technologies and/or frameworks to use.The application will be an Intranet-based web site using Windows authentication, running on IIS and using SQL Server and ASP.NET. It'll need to be structured as a main/shell application with sub-applications that are "pluggable" based on some configuration settings.
I'm designing my first asp.net web app, using nHibernate as the data provider. i've read a lot about nhibernate in web applications using session-per-request pattern. my application will have a few pages which are 'monitors', meaning- they're updated automatically every few seconds to reflect recent changes to data. in that case, my thought is that opening a session for every request would not make much sense, since I know that an identical request is sure to follow in a few seconds. my thought is that session-per-conversation would make more sense for me, but I'm having trouble finding examples of implementations. I'd appreciate any good resources for how to implement session-per-conversation
I have to build a web application from scratch(a 4-layer architecture). give me a checklist that are required such as tools, how to create the projects and their references,writing base page classes, how to set up and configure the application in Visual studio(asp.net 2.0 or above versions) ,IIS, database server, source safe and cruise control tools as well as the structure of the project.