Exemplo n.º 1
0
        private User CreateTenderOwner(TenderOwnerUser user, string password)
        {
            Guid token = Guid.NewGuid();

            using (SqlConnection conn = new SqlConnection(_connectionString))
            {
                conn.Open();

                using (SqlCommand comm = conn.CreateCommand())
                {
                    comm.CommandType = System.Data.CommandType.StoredProcedure;
                    comm.CommandText = "[CreateUser]";

                    comm.Parameters.AddRange(new[]
                    {
                        new SqlParameter("@type", (int)user.Type),
                        new SqlParameter("@name", user.Name),
                        new SqlParameter("@password", password),
                        new SqlParameter("@email", user.Email),
                        new SqlParameter("@firstName", user.FirstName),
                        new SqlParameter("@lastName", user.LastName),
                        new SqlParameter("@activationToken", token),
                        new SqlParameter("@telNo", user.TelephoneNumber),
                        new SqlParameter("@nip", user.NIP.Replace(",", "").Replace(" ", "")),
                        new SqlParameter("@krs", user.KRS + "  Wydział Gospodarczy KRS"),
                        new SqlParameter("@regon", user.REGON),
                        new SqlParameter("@companyName", user.CompanyName)
                    });

                    comm.ExecuteNonQuery();
                }
            }

            IMailer mailer = new Mailer();
            mailer.SendMail(new[] { user.Email }, "Potwierdzenie rejestracji", token.ToString());

            return AuthenticateUser(user.Name, password, user.Type);
        }
Exemplo n.º 2
0
        private User CreateTenderAttendee(TenderAttendeeUser user, string password)
        {
            Guid token = Guid.NewGuid();

            using (SqlConnection conn = new SqlConnection(_connectionString))
            {
                conn.Open();

                using (SqlCommand comm = conn.CreateCommand())
                {
                    comm.CommandType = System.Data.CommandType.StoredProcedure;
                    comm.CommandText = "[CreateUser]";

                    comm.Parameters.AddRange(new[]
                    {
                        new SqlParameter("@type", (int)user.Type),
                        new SqlParameter("@name", user.Name),
                        new SqlParameter("@password", password),
                        new SqlParameter("@email", user.Email),
                        new SqlParameter("@activationToken", token),
                        new SqlParameter("@firstName", user.FirstName),
                        new SqlParameter("@lastName", user.LastName)
                    });

                    comm.ExecuteNonQuery();
                }
            }

            IMailer mailer = new Mailer();
            mailer.SendMail(new [] { user.Email }, "Potwierdzenie rejestracji", token.ToString());

            return AuthenticateUser(user.Name, password, user.Type);
        }