Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["User"] != null)
            {
                HeftITGemer.UserInfo ui = (HeftITGemer.UserInfo)Session["User"];

                Adress adress = new Adress(Request.Form["country"], Request.Form["city"], Request.Form["street"], Request.Form["zip"], Request.Form["phone"], Request.Form["department"]);

                int baid = Adress.AddAdress(adress);

                ui.BillingadressID  = baid;
                ui.DeliveryadressID = baid;

                Session["User"] = ui;
                Response.Write($"{baid} \r\n");
                Response.StatusCode = 200;
                Response.End();
            }
            else
            {
                Adress adress = new Adress(Request.Form["country"], Request.Form["city"], Request.Form["street"], Request.Form["zip"], Request.Form["phone"], Request.Form["department"]);

                int baid = Adress.AddAdress(adress);
                Response.Write($"{baid} \r\n");
                Response.StatusCode = 200;
                Response.End();
            }
        }
Exemplo n.º 2
0
        static void TestUserFlow()
        {
            Adress   a   = new Adress("Sweden", "Karlstad", "Signalhornsgatan 66", "65634", "0", " ");
            int      aid = Adress.AddAdress(a);
            UserInfo ui  = new UserInfo("Test", "Testsson", "0", " ", aid, aid);
            User     u   = SQL.AddUser("*****@*****.**", "PASSWO", ui);
            User     tst = SQL.GetUserByEmail("*****@*****.**");

            Console.WriteLine($"User has password PASSWO? {SQL.Login(tst, "PASSWO")}");

            tst = SQL.GetUserByEmail("*****@*****.**");
            tst = SQL.GetUserByEmail("*****@*****.**");
            Console.WriteLine($"Fetched 4 users.");
        }
Exemplo n.º 3
0
Arquivo: SQL.cs Projeto: vwarg/P1G6
 public static User AddUser(string email, string password, UserInfo ui = null)
 {
     User toAdd = new User();
     toAdd.Email = email;
     toAdd.Password = PasswordHelper.GetHash(password);
     UserInfo userInfo = ui;
     if (userInfo == null)
     {
         userInfo = new UserInfo("", "", "", "", -1, -1);
         Adress a = new Adress("", "", "", "", "", "");
         int aid = Adress.AddAdress(a);
         userInfo.BillingadressID = aid;
         userInfo.DeliveryadressID = aid;
     }
     else
     {
         if (userInfo.DeliveryadressID < 0)
         {
             Adress a = new Adress("", "", "", "", "", "");
             int aid = Adress.AddAdress(a);
             userInfo.DeliveryadressID = aid;
         }
         if (userInfo.BillingadressID < 0)
         {
             Adress a = new Adress("", "", "", "", "", "");
             int aid = Adress.AddAdress(a);
             userInfo.BillingadressID = aid;
         }
     }
     int uiid = UserInfo.AddUserInfo(userInfo);
     toAdd.Contactinfo = uiid;
     int uid = AddUser(toAdd.Email, toAdd.Password, toAdd.Contactinfo);
     toAdd.ID = uid;
     UpdateUserCache();
     return toAdd;
 }