public void InsertUserInformation(InformacjeOKlientach info)
    {
        KosmetykiDBEntities db = new KosmetykiDBEntities();

        db.InformacjeOKlientaches.Add(info);
        db.SaveChanges();
    }
    public InformacjeOKlientach GetUserInformation(string guId)
    {
        KosmetykiDBEntities  db   = new KosmetykiDBEntities();
        InformacjeOKlientach info = (from x in db.InformacjeOKlientaches
                                     where x.GUID == guId
                                     select x).FirstOrDefault();

        return(info);
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        UserStore <IdentityUser> userStore = new UserStore <IdentityUser>();

        userStore.Context.Database.Connection.ConnectionString =
            System.Configuration.ConfigurationManager.
            ConnectionStrings["KosmetykiDBConnectionString"].ConnectionString;

        UserManager <IdentityUser> manager = new UserManager <IdentityUser>(userStore);

        //create new user and try to store in DB
        IdentityUser user = new IdentityUser();

        user.UserName = txtUserName.Text;

        if (txtPassword.Text == txtConfirmPassword.Text)
        {
            try
            {
                //create user object
                //database will be created / expanded automatically
                IdentityResult result = manager.Create(user, txtPassword.Text);

                if (result.Succeeded)
                {
                    InformacjeOKlientach info = new InformacjeOKlientach
                    {
                        Address    = txtAddress.Text,
                        FirstName  = txtFirstName.Text,
                        LastName   = txtLastName.Text,
                        PostalCode = Convert.ToInt32(txtPostalCode.Text),
                        GUID       = user.Id
                    };

                    UserInfoModel model = new UserInfoModel();
                    model.InsertUserInformation(info);

                    //store user in DB
                    var authenticationManager = HttpContext.Current.GetOwinContext().Authentication;

                    //set to log in new user by cookie
                    var userIdentity = manager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie);

                    //log in the new user and redirect to homepage
                    authenticationManager.SignIn(new AuthenticationProperties(), userIdentity);
                    Response.Redirect("~/Index.aspx");
                }
                else
                {
                    litStatus.Text = result.Errors.FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                litStatus.Text = ex.ToString();
            }
        }


        else
        {
            litStatus.Text = "Hasła muszą być takie same ";
        }
    }