Ejemplo n.º 1
0
        public int NewUser(byte AccType, string Login, string Password, string Email, string Name, string Surname, string Street, string City, string ZipCode, string HouseNumber, string BlockNumber, string FlatNumber)
        {
            int LoginUsed = 1;
            int EmailUsed = 2;
            int Success   = 3;

            var query_login = from db in database.UzytkownicyPKs
                              where db.login == Login
                              select db;

            var query_email = from db in database.UzytkownicyPKs
                              where db.mail == Email
                              select db;

            UzytkownicyPK NewAcc = new UzytkownicyPK();

            NewAcc.login         = Login;
            NewAcc.haslo         = Password;
            NewAcc.mail          = Email;
            NewAcc.imie          = Name;
            NewAcc.nazwisko      = Surname;
            NewAcc.miasto        = City;
            NewAcc.k_pocztowy    = ZipCode;
            NewAcc.ulica         = Street;
            NewAcc.nr_domu       = HouseNumber;
            NewAcc.nr_bloku      = BlockNumber;
            NewAcc.nr_mieszkania = FlatNumber;
            NewAcc.typ_konta     = AccType;

            switch (AccType)
            {
            case 1:
                if (query_login.Any())
                {
                    return(LoginUsed);
                }
                else if (query_email.Any())
                {
                    return(EmailUsed);
                }
                else
                {
                    database.UzytkownicyPKs.InsertOnSubmit(NewAcc);
                    try
                    {
                        database.SubmitChanges();
                        return(Success);
                    }
                    catch (Exception e)
                    {
                        throw e;
                    }
                }

            default:
                if (query_login.Any())
                {
                    return(LoginUsed);
                }
                else if (query_email.Any())
                {
                    return(EmailUsed);
                }
                else
                {
                    database.UzytkownicyPKs.InsertOnSubmit(NewAcc);
                    try
                    {
                        database.SubmitChanges();
                        return(Success);
                    }
                    catch (Exception e)
                    {
                        throw e;
                    }
                }
            }
        }
Ejemplo n.º 2
0
 partial void UpdateUzytkownicyPK(UzytkownicyPK instance);
Ejemplo n.º 3
0
 partial void DeleteUzytkownicyPK(UzytkownicyPK instance);
Ejemplo n.º 4
0
 partial void InsertUzytkownicyPK(UzytkownicyPK instance);