C# - How To Fetch Session Values Inside Business Logic Layer

Aug 23, 2010

I have to pass the session value to a business logic layer, I can pass it to the function from presentation layer but how can I access it directly in my business logic layer ? Also is it a good approach to pass it directly to business logic layer like

GetMyRecords(Count,Session["userID"].toString()); ?

View 2 Replies


Similar Messages:

Architecture :: How To Pass The Values From Presentation Layer To Business Logic Layer

Oct 26, 2010

I am new to this .NET what is the difference between N-Tier and 3- Tier Architecture. If they are same. How to pass the values from presentation layer to business logic layer.

For Example

I have 10 controls in presentation layer. I passing values to these controls. How the architecture works.

View 3 Replies

Architecture :: Data Access Layer And Business Logic Layer?

Jun 24, 2010

I am building a web site following the tutorials on asp.net. I am using dataset as data access lay, and writing classes to access the dataset. But the example is just basic ideas, how do I retrieve individual table column value in the business layer?For example, if I have a table called Product, I only want to find out what is the product name by product id. I did this in my ProductBLL:

public ProductBLL
{
public int GetProductName(string productId)
{
ProductDataSet.ProductDataTable prodData = Adapter.GetProductById(productId);
[code]...

Is there a better way, or am I doing this correctly? Can anybody give me a reference to a more complicated business logic model?

View 16 Replies

Implement Transaction In Business Logic Layer?

Jan 17, 2011

I'am using enterprise library data access block in my asp.net application. I want to implement transaction from the Business logic layer, across multiple stored procs. Entlib opens a new connection for database access. Does using Transaction Scope in the following way lead to distributed transaction?

using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
{
// calling necessary DAL methods
scope.Complete();
}

Is there better methods to implement transaction from BLL?

View 1 Replies

Classic ASP App Has COM 'middle Layer' For Light Business Logic?

Oct 19, 2010

I am trying to estimate how long it will take to migrate a Classic ASP application to .NET and came across hundreds of COM functions written in VB 6.

A majority of these functions only do parameter validation and actually calls the SQL server. Is this something that should be replace with an ORM? (Linq, nHibernate, Entity Framework)... or should there be more to this picture?

View 1 Replies

Calling Business Logic Layer Method From PageMethods?

Jul 12, 2010

I've a static page method in web form application and I want to call method on private class level variable from it as shown below. I'm using jQuery to call the page method.

private readonly ICatalogBLL _catalogBLL = new CatalogBLL();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
_catalogBLL.GetSomething();
}
}
[WebMethod]
public static UpdateSomething(int i)
{
//Want to do as below. But can't call it from a static method.
_catalogBLL.UpdateSomething();
}

UPDATE If I call it as said by John Saunders, won't it use the same instance for requests from different users as it is within a static method?

View 2 Replies

Web Forms :: Exceptions From Business Logic Layer Not Caught In Application_Error?

Nov 11, 2010

I know there are a few posts on this issue already, however I haven't found the answers I was really looking for.

My situation is like this: I have a DLL project containing my business logic. Then I have a web application that refers to this DLL, and calls a function from it. And I have a global.asax which handles errors on Application_Error

Sample:

// MyWebsite.aspx.cs
using MyBusinessLogic;
protected void Page_Load(object sender, EventArgs e)
{
MyBusinessLogicClass.DoSomething();
}
// global.asax.cs
protected void Application_Error(object sender, EventArgs e)

[Code].....

View 6 Replies

Architecture - Removing Session Calls From Business Logic?

Feb 4, 2011

I've inherited an asp.net web solution, which has business logic and data calls as seperate assemblies. In the business layer there are a small number of calls to get/set HttpContext session values. I've looked around for an example that will allow me to abstract this away from the business logic as I'd like to be able to reuse these assemblies in non-web projects, could anyone please give me an example of the best way to do this. I was thinking of some sort of session factory that will obtain values from some sort of persistant store depending on the usage scenario but I'm new to architecture really and would appreciate a pointer or two.

View 3 Replies

Setting A Default Value -- Presentation Logic Or Business Logic?

Jun 18, 2010

I was wondering if setting a default value for a SelectList is considered to be presentation logic or business logic? For example, if a requirement is that an Employee cannot be saved without a Location, but 99% of the time the location that would be selected is a particular item -- say Atlanta. Because of this, the location SelectList should be defaulted to Atlanta when ever a entry screen for a new employee is displayed. Should I be defaulting the location in the model or in the view-model? One thing I realized is that the unit tests become awkward because in both cases, I'd be forced to test against a location that will always be present in production but I cannot create a unit test with my own test dataunless "Atlanta" was in the set of locations being used in the test.

View 4 Replies

MVC :: How To Make Business Layer Seperate From Presentation Layer

Feb 23, 2011

I've even got my JQuery Ajax submission going on now but I've encountered another problem. I *think* it's something to do with the structure I'm using but like I say, I'm fairly newo this.I have my AJAX form submission which builds my "PersonViewModel" (model for the presentation layer) in JSON and sends it to "@Url.Action("RegisterSubmit")" in my Person Controller. Now, I seperate my business layer from my View/presentation layer so in "RegisterSubmit"I'm verifying the model is valid then instantiating a new instance of my business model "Person", adding the values from "PersonViewModel" and then calling my "Save" function.

View 7 Replies

Business Layer Errors And Service Layer Handling?

Mar 7, 2011

We're building a large web app that has numerous layers. In order to communicate to the business layer we're using a service layer that the web layer calls when data is needed. Unfortunately, it seems that if exceptions are thrown in the business layer, it seems that the services on the web side are wrapping the exceptions and re-throwing them. We're looking for a clear way to encapsulate the error and log it, without WCF wrapping a new exception around the original.

View 2 Replies

C# - N-layer Business/service Layer Design?

Jan 26, 2011

I'm trying to reevaluate our n-layer architecture and would love to get some based on your experiences. Here is our typical .NET n-layer (sometimes n-tier) design.

Project.UI
Project.Services
Project.Business
Project.Model
Project.DataAccess

DataAccess typically consists of Entity Framework 4 and Repository classes. I attempt to follow the Aggregate Root concept in order to avoid having a repository for table, easier said than done in my experience. I tend to have ~70% match between Repositories and Tables.

Model usually consists of my Entity Framework 4 entities, I've been using Self-Tracking EF entities with success.

Business is what I struggle with the most. I typically have a Manager class for every Repository. This class will contain methods like .Add() which will perform business validation before forwarding down to repository.Add().

Services, typically I will only implement this if in fact I am looking to create a web service based solution. This layer will be tasked with marshaling requests/responses between DTOs and entities. And most importantly provide the more coarse grained interface. For example a TradingService.SubmitTrade(), which is really a facade for a business transaction which might include AccountManager.ValidateCash(), OrderManager.SubmitOrder(), etc.

My business layer is very entity centric, really it's just the glue between the entities and the repository, with validation in between. I've seen many designs where the Service Layer is what holds a reference to the repositories (in essence skipping the "business layer"). In essence it serves the same purpose as my Business layer, it does the validation, however its' responsibility (and naming) is a higher level, more coarse grained business transaction. Using the example above the TradingService.submitTrade() will not delegate to any business manager classes, it would itself query the necessary repositories, perform all the validation etc.

I like my design in a sense that I can reuse a business layer method in multiple service calls, however I hate the fact that for every repository I have a matching business layer manager, creating tons of extra work. Maybe the solution is a different type of grouping at the Business Layer level? For example combine individual Manager classes like PhoneManager and EmailManager (note I have Phone entities and Email entities) into a logical Manager class such as ContactsManager (note I don't have a "Contact" entity type). With methods such as ContactManager.GetPhones() and ContactManager.GetEmail(), etc.

View 1 Replies

Architecture :: How To Pass The Data Between Data Access Layer And Business Acces Layer

Jun 3, 2010

here i have in 3-tier architecture , how to pass the data between DAL and BAL. i am using grid view to edit the data,when ever i click on the edit button all the corresponding fields should come to textboxes. i tried for delete ,it works fine bt not working to EDIT.

View 7 Replies

How To Access Session Values From Layers Beneath The Web Application Layer

Apr 23, 2010

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.

View 3 Replies

MVC :: How To Use Business Logic

Nov 21, 2010

I've got a C# MVC 2 application using EF 4. My DAL project gets data from the Model, translates them into POCO's and returns ViewModels to the BLL which is called from the controllers.I've set up validation attributes on the POCO classes and that works for "Required" fields etc. I would like to add business logic such as "From" has to be before the "To" date. Can this be done on the POCO classes so it is automatically validated client-side in the view?

Also, I would like to add some functionality to the BLL layer such as checking if a resource is already booked between the From and To dates to avoid double bookings. This should fire before the ViewModel is saved. I tried a Try/Catch statement in the controller so that I can throw an error in the BLL, but I don't understand how to return this error to the view with an appropriate error message added.

View 2 Replies

DataSource Controls :: How To Fetch Rows Based On Values In A Session Variable

Dec 23, 2010

How to Fetch Rows based on Values in a Session Variable

View 4 Replies

Where To Write Database And Business Logic In MVC

Sep 9, 2010

As I am learning and working on Asp.Net MVC application, I want to know that what is the better place to write Business Logic and Data Access logic in MVC.Where should I write DataAccess and Business Logic among three layers (Model, View and Controller) ??Could anybody please tell me the correct way to write the code for this.Scenario: I want to retrieve all the employees where employee name like 'Mi%' ( I have SQL procedure to execute and retrieve the data.)PS: Want to know that where I should create instance of Business Logic class and where I should create instance of Data Access layers class?

View 3 Replies

Mvc Linq 2 SQL Model : Where Is The Business Logic

Sep 16, 2010

I'm building a first MVC app in ASP.NET and I'm using link2SQL model to work with data.All tutorials on the microsoft site let you write LINQ code in the controller to get data and pass it to the view, like this:

Function Index() As ActionResult
Dim datacontext As New ErrorVaultDataContext
Dim questions = From q In datacontext.Questions

[code]...

View 3 Replies

Business Logic Not Exposed On Formview

Oct 16, 2010

I have to maintain an ASP.net application in VB.Net. There is a page with a FormView bound to a ObjectDataSource. I have to add some business logic on the ItemUpdating event of this FormView. Unfortunately, some the data that I need to add this business logic is not exposed on the FormView user-interface itself, so I can not use FindControl to get the values (I could add the controls, bind them to the fields I need and set their visible property to true, but that's ugly).

So, what I would need to do is to get access to the Data Row corresponding to the currently selected item in the FormView from the code behind as it has the data I need to add my business logic code. Unfortunately, I don't manage to get access to the row.

View 2 Replies

Business Logic In Stored Procedures?

Mar 8, 2011

Suppose you have to query a lot of tables and calculate some values and spit it out to the user. Is it ok to have all the business logic for this in the stored procedures? Or is it a better practice to return all the data to the application and do all the data manipulation and rolling up in there?

View 6 Replies

C# - Protecting Business Logic In Webservices?

May 8, 2010

Is there a way that a hacker or someone who wants to copy my software logic, can reverse engineer the business logic that I have in a webservice?

Is there a way to protect such information?

My development platform in .net asp.net and C#

View 3 Replies

DataSource Controls :: Put Business Logic In Sql Or C#?

May 5, 2010

what's is better?That I put my business logic in the sqls(DataStore) or in the C#.DataSore:

[Code]....

What's faster and better?

View 4 Replies

Access A Flag Set In Sql Server Into Business Logic?

Jan 4, 2011

public int InsertCompanyDetailsInformation(int companyId, int bankId, int accountNo, string accountType)
{
int rowsAffected = -1;
int returnValue;
try
{
SqlConnection con = DBProvider.GetDbConnection();
using (con)
{
con.Open();
SqlCommand objCmd = new SqlCommand("dbo.sp_InsertCompanyDetailsInformation", con);
objCmd.CommandType = CommandType.StoredProcedure;
objCmd.Parameters.AddWithValue("@companyId", companyId);
objCmd.Parameters.AddWithValue("@bankId", bankId);
objCmd.Parameters.AddWithValue("@accountNo", accountNo);
objCmd.Parameters.AddWithValue("@accountType", accountType);
rowsAffected = objCmd.ExecuteNonQuery();
SqlParameter sqlParam = objCmd.Parameters.Add("@insert_flag", SqlDbType.Int);
objCmd.Parameters["@insert_flag"].Direction = ParameterDirection.ReturnValue;
returnValue = int.Parse(objCmd.Parameters["@insert_flag"].Value.ToString());
con.Close();
}
}
catch (Exception ex)
{
throw ex;
}
return rowsAffected;
}
and stored procedure
USE [SGTime_Development]
GO
/****** Object: StoredProcedure [dbo].[sp_InsertCompanyDetailsInformation] Script Date: 01/04/2011 14:31:09 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sp_InsertCompanyDetailsInformation]
(
@companyId int,
@bankId int,
@accountNo int,
@accountType varchar(50))
AS
BEGIN
SET NOCOUNT ON;
declare @insert_flag int;
if not exists(select AccountNo from [Company_Account_Details] where
AccountNo=@accountNo)
begin
INSERT INTO [Company_Account_Details]
( Company_Id,
BankID,
AccountNo,
AccountType)
values
(@companyId,
@bankId,
@accountNo,
@accountType)
set @insert_flag=1;
END
else
begin
set @insert_flag=-1;
end
return @insert_flag;
end

I am getting error in the code i want return returnValue in InsertCompanyDetailsInformation. how we can return returnValue

View 4 Replies

How To Separate Business Logic And Database Calls From A WCF Web Service

Jun 3, 2010

This question may have been asked before, but I'm looking for a different answer than what I've seen.

Our website is in ASP.NET and we use the model-view-presenter pattern to get business logic out of the markup codebehind.

Is there an accepted pattern for web services for getting business logic out of the codebehind? It seems like putting the logic in a 'presenter' is misleading since the calls don't really present anything to the user, and may not even send back data to the client.

View 1 Replies

MVC :: Calling Business Logic In Model From Submit Tag In View?

Jun 30, 2010

Currently I am working on a project at work that deals with MVC. I have never used MVC before, only dealt a little with ASP with VB, and that's it. I've dabbled in HTML but not much. I don't currently have the money for a book, so I'm using this forum. So there's a lot of jargon I may not pick up on or may ask a lot of questions, so please bare with me.Anyways here's what I would like to do, or understand. We're using ASP.NET Membership Security (not sure if that's what it's actually called) for passwords and accounts. My issue is that I've been working on other projects while the rest of my team has been working on this, so they know more about it than I do. And I don't want to take too long to understand it, but I have to find the best way to make sure the following doesn't happen:

1) When changing a password, it can't be within the last 10 passwords used for that user.2) When creating/changing a password, it cannot have dictionary words, names, phone numbers or personal data within it.3) The password must be a minimum of 16 characters.Number 3 is rather easy and completed I believe. However, 1 and 2 prove tenuous. We want to store the previous passwords hashed and we were going to save the salt used. However, I'm beginning to think that with the Membership class you can't specify the salt to hash a password. Is there a way to de-hash a password? We do not want to store the passwords as plaintext, so that is out of the question.I believe the best order (for 1 and 2) is to do 2 first (before it's hashed) and then 1. For two, I need to know how to call a function in the Model code from a <submit> tag in the View code. I've done a little research online but thought I'd ask and see if it gets answered while I'm looking for the answer.

In general, my questions are:1) How do I call a function in the ****Model.cs from a <submit> tag in the *******.aspx?2) What's the best way to compare previous passwords that are hashed? 3) If I know the salt, can I de-hash a password? (I believe the answer to this is no.)4) Can I specify the salt to hash a password? (I believe the answer to this is no.)5) If #3 and #4 are no, then should I do encryption instead of hashing?Details: MVC2, C#, Membership.

View: Account/ChangePassword.aspx

[Code]....

Model: AccountModel.cs

View 16 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved