Click here to Skip to main content
15,894,907 members
Home / Discussions / C#
   

C#

 
QuestionRe: Help needed in C# Pin
Ed Hill _5_30-Jul-12 22:57
Ed Hill _5_30-Jul-12 22:57 
GeneralResponse.Write doenst work correctly ...? Pin
jojoba201130-Jul-12 20:08
jojoba201130-Jul-12 20:08 
GeneralRe: Response.Write doenst work correctly ...? Pin
Bernhard Hiller30-Jul-12 20:47
Bernhard Hiller30-Jul-12 20:47 
AnswerRe: Response.Write doenst work correctly ...? Pin
jojoba201130-Jul-12 21:31
jojoba201130-Jul-12 21:31 
GeneralRe: Response.Write doenst work correctly ...? Pin
Dave Kreskowiak31-Jul-12 2:29
mveDave Kreskowiak31-Jul-12 2:29 
QuestionHai sir Pin
Mars selva30-Jul-12 20:00
Mars selva30-Jul-12 20:00 
AnswerRe: Hai sir Pin
Abhinav S30-Jul-12 20:08
Abhinav S30-Jul-12 20:08 
QuestionQuick Data Layer Design Question Pin
Kevin Marois30-Jul-12 8:54
professionalKevin Marois30-Jul-12 8:54 
Assume a table called tblCompanies and another called tblUsers. Each Company can have one or more Users.

So I have this AddUser method. See the comments in-line

private int AddUser(UserEntity User)
{
    int retVal = 0;

    using (var dc = getDataContext())
    {
        var user = (from u in dc.tblUsers
                    where u.CompanyId == User.CompanyId &&
                            u.UserName.Trim().ToLower() == User.UserName.Trim().ToLower()
                    select u).FirstOrDefault();

        if (user == null)
        {
            tblUser newUser = new tblUser
            {
                CompanyId = User.CompanyId,
                RoleId = User.RoleId,
                FirstName = User.FirstName,
                LastName = User.LastName,
                UserName = User.UserName,
                Password = User.Password,
                CanLogIn = User.CanLogIn
            };

            // Wrap this in a try/catch, or handle exceptions in the BLL?
            dc.tblUsers.InsertOnSubmit(newUser);
                    
                    
            retVal = newUser.UserId;
        }
        else
        {
            // If here, the user already exists. Throw an exception here?
        }
    }

    return retVal;
}


Aside from try/catch & exceptions, what about the 2 potential FK violations on CompanyId and RoleId?

What's the right way to handle all this. I'v heard people say "Handle these issues in the BLL", while other folks seem to think exceptions related to data should be handled in the DAL?

What's your thoughts?
If it's not broken, fix it until it is

AnswerRe: Quick Data Layer Design Question Pin
Pete O'Hanlon30-Jul-12 10:06
mvePete O'Hanlon30-Jul-12 10:06 
GeneralRe: Quick Data Layer Design Question Pin
Kevin Marois30-Jul-12 10:25
professionalKevin Marois30-Jul-12 10:25 
AnswerRe: Quick Data Layer Design Question Pin
Eddy Vluggen30-Jul-12 11:32
professionalEddy Vluggen30-Jul-12 11:32 
AnswerRe: Quick Data Layer Design Question Pin
BobJanova31-Jul-12 0:27
BobJanova31-Jul-12 0:27 
AnswerRe: Quick Data Layer Design Question Pin
PIEBALDconsult31-Jul-12 6:33
mvePIEBALDconsult31-Jul-12 6:33 
QuestionCircular list as vector, lock needed? Pin
George Nistor30-Jul-12 5:45
George Nistor30-Jul-12 5:45 
AnswerRe: Circular list as vector, lock needed? Pin
OriginalGriff30-Jul-12 6:07
mveOriginalGriff30-Jul-12 6:07 
GeneralRe: Circular list as vector, lock needed? Pin
dybs30-Jul-12 8:07
dybs30-Jul-12 8:07 
GeneralRe: Circular list as vector, lock needed? Pin
OriginalGriff30-Jul-12 8:12
mveOriginalGriff30-Jul-12 8:12 
GeneralRe: Circular list as vector, lock needed? [Modified] Pin
Wes Aday30-Jul-12 8:51
professionalWes Aday30-Jul-12 8:51 
GeneralRe: Circular list as vector, lock needed? Pin
George Nistor30-Jul-12 21:43
George Nistor30-Jul-12 21:43 
GeneralRe: Circular list as vector, lock needed? Pin
George Nistor30-Jul-12 23:48
George Nistor30-Jul-12 23:48 
Questionc# Pin
sutapa das29-Jul-12 20:30
sutapa das29-Jul-12 20:30 
AnswerRe: c# Pin
Abhinav S29-Jul-12 20:46
Abhinav S29-Jul-12 20:46 
Questionhow to create monthly calander in c#? Pin
sutapa das29-Jul-12 20:27
sutapa das29-Jul-12 20:27 
AnswerRe: how to create monthly calander in c#? Pin
Midnight Ahri29-Jul-12 20:40
Midnight Ahri29-Jul-12 20:40 
GeneralRe: how to create monthly calander in c#? Pin
Richard MacCutchan29-Jul-12 21:54
mveRichard MacCutchan29-Jul-12 21:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.