示例#1
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Klinet EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToKlinet(Klinet klinet)
 {
     base.AddObject("Klinet", klinet);
 }
示例#2
0
 /// <summary>
 /// Create a new Klinet object.
 /// </summary>
 /// <param name="nrKlienta">Initial value of the NrKlienta property.</param>
 /// <param name="imie">Initial value of the Imie property.</param>
 /// <param name="nazwisko">Initial value of the Nazwisko property.</param>
 /// <param name="e_Mail">Initial value of the E_Mail property.</param>
 /// <param name="nIP">Initial value of the NIP property.</param>
 /// <param name="telefon">Initial value of the Telefon property.</param>
 /// <param name="login">Initial value of the Login property.</param>
 /// <param name="rola_w_systemie">Initial value of the Rola_w_systemie property.</param>
 public static Klinet CreateKlinet(global::System.Decimal nrKlienta, global::System.String imie, global::System.String nazwisko, global::System.String e_Mail, global::System.String nIP, global::System.String telefon, global::System.String login, global::System.String rola_w_systemie)
 {
     Klinet klinet = new Klinet();
     klinet.NrKlienta = nrKlienta;
     klinet.Imie = imie;
     klinet.Nazwisko = nazwisko;
     klinet.E_Mail = e_Mail;
     klinet.NIP = nIP;
     klinet.Telefon = telefon;
     klinet.Login = login;
     klinet.Rola_w_systemie = rola_w_systemie;
     return klinet;
 }
示例#3
0
        public ActionResult Register(string imie, string nazwisko, string nip, string tel, string userName, string email, string password, string confirmPassword,
            string city,string citycode, string street, string streetNo)
        {
            ViewData["PasswordLength"] = MembershipService.MinPasswordLength;
            Response.AppendHeader("X-XSS-Protection", "0");

            if (ValidateRegistration(userName, email, password, confirmPassword))
            {
                // Attempt to register the user
                MembershipCreateStatus createStatus = MembershipService.CreateUser(userName, password, email);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    //ustawienie go jako klienta
                    Roles.AddUserToRole(userName, "Klient");

                    string hash = BitConverter.ToString(SHA1Managed.Create().ComputeHash(Encoding.Default.GetBytes(password))).Replace("-", "");
                    Debug.WriteLine("Długość wynosi: " + hash.Length);

                    //tworzenie nowego klienta
                    Klinet kl = new Klinet();
                    kl.Imie = imie;
                    kl.Nazwisko = nazwisko;
                    kl.E_Mail = email;
                    kl.NIP = nip;
                    kl.Telefon = tel;
                    kl.Login = userName;
                    kl.Haslo = hash;
                    kl.Rola_w_systemie = "kl";
                    db.AddToKlinet(kl);
                    db.SaveChanges();

                    var nrk = (from p in db.Klinet
                               where p.NIP == nip
                               select p.NrKlienta
                               ).First();

                    //tworzenie adresu
                    Adres ad = new Adres();
                    ad.Kod = citycode;
                    ad.Miasto = city;
                    ad.NrDomu = streetNo;
                    ad.Ulica = street;
                    ad.NrKlienta = nrk;
                    db.AddToAdres(ad);
                    db.SaveChanges();

                    FormsAuth.SignIn(userName, false /* createPersistentCookie */);
                    return RedirectToAction("Index", "Home");
                }
                else
                {
                    ModelState.AddModelError("_FORM", ErrorCodeToString(createStatus));
                }
            }

            // If we got this far, something failed, redisplay form
            return View();
        }