public int RegisterNewUser(RegistrationInformation registerInformation)
        {
            Address            address      = registerInformation.PhysicalAddress;
            Customer           customer     = registerInformation.Customer;
            User               user         = registerInformation.User;
            List <PhoneNumber> phoneNumbers = registerInformation.PhoneNumbers;

            if (address != null && customer != null && user != null && phoneNumbers.First() != null)
            {
                address.IsActive  = true;
                customer.IsActive = true;
                user.IsActive     = true;
                Context.Add(address);
                Context.SaveChanges();
                customer.IdAddress = address.Id;
                Context.Add(customer);
                Context.SaveChanges();
                if (user.Email != "" && user.Password != "")
                {
                    user.IdCustomer = customer.Id;
                    user.LastLogin  = DateConverter.CurrentEasternDateTime();
                    user.CreatedOn  = DateConverter.CurrentEasternDateTime();
                    Context.Add(user);
                }
                Context.SaveChanges();
                foreach (var phone in phoneNumbers)
                {
                    phone.IsActive   = true;
                    phone.IdCustomer = customer.Id;
                    Context.Add(phone);
                }
            }
            Context.SaveChanges();
            return(customer.Id);
        }
Exemple #2
0
        public void SendRegistrationInfoAsync_ValidInfo_SendsMessagesToServer()
        {
            const string password = "******";
            const string nickname = "iluvcats92";
            const string user     = "******";
            const string realName = "John Smith";

            var registrationInfo = new RegistrationInformation
            {
                Nickname = nickname,
                Password = password,
                Username = user,
                RealName = realName
            };

            _mockClient.Setup(
                f =>
                f.SendMessageToServerAsync(It.Is <IrcMessage>(m => m.Command == "PASS" && m.Parameters.Contains(password))))
            .Returns(Task.Delay(0)).Verifiable();

            _mockClient.Setup(
                f =>
                f.SendMessageToServerAsync(It.Is <IrcMessage>(m => m.Command == "NICK" && m.Parameters.Contains(nickname))))
            .Returns(Task.Delay(0)).Verifiable();

            _mockClient.Setup(
                f =>
                f.SendMessageToServerAsync(It.Is <IrcMessage>(m => m.Command == "USER" && m.Parameters.Contains(user) && m.Parameters.Contains(realName))))
            .Returns(Task.Delay(0)).Verifiable();

            _client.SendRegistrationInfoAsync(registrationInfo).Wait();
        }
Exemple #3
0
        public async Task <IActionResult> Register([FromBody] RegistrationInformation registrationInformation)
        {
            if (string.IsNullOrWhiteSpace(registrationInformation.Username))
            {
                return(BadRequest("Username must not be empty"));
            }
            if (string.IsNullOrEmpty(registrationInformation.Password))
            {
                return(BadRequest("Password must not be empty"));
            }
            if (string.IsNullOrWhiteSpace(registrationInformation.Email))
            {
                return(BadRequest("Email must not be empty"));
            }
            var existingUser = await authenticationModule.FindUserAsync(registrationInformation.Username);

            if (existingUser != null)
            {
                return(Conflict($"User '{registrationInformation.Username}' already exists"));
            }

            var newUser = UserFactory.Create(registrationInformation);

            if (!await authenticationModule.CreateUserAsync(newUser))
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError));
            }
            apiEventLogger.Log(LogLevel.Info, $"New user '{newUser.UserName}' added");
            return(Ok());
        }
Exemple #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!PreviousPage.IsValid)
            {
                labelResult.Text = "Error in previous page";
                return;
            }

            RegistrationInformation ri = PreviousPage.RegistrationInformation;

            labelResult.Text = String.Format("{0} {1} selected the event {2}",
                                             ri.FirstName, ri.LastName, ri.SelectedEvent);

            //DropDownList dropDownListEvents =
            //   (DropDownList)PreviousPage.FindControl("dropDownListEvents");

            //string selectedEvent = dropDownListEvents.SelectedValue;

            //string firstName =
            //   ((TextBox)PreviousPage.FindControl("textFirstName")).Text;
            //string lastName =
            //   ((TextBox)PreviousPage.FindControl("textLastName")).Text;
            //string email = ((TextBox)PreviousPage.FindControl("textEmail")).Text;

            //labelResult.Text = String.Format("{0} {1} selected the event {2}",
            //      firstName, lastName, selectedEvent);
        }
        catch
        {
            labelResult.Text = "The originating page must contain " +
                               "textFirstName, textLastName, textEmail controls";
        }
    }
        public ActionResult DeleteConfirmed(string id)
        {
            RegistrationInformation registrationInformation = db.RegistrationInformations.Find(id);

            db.RegistrationInformations.Remove(registrationInformation);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult RegisterNewUser([FromBody] RegistrationInformation registrationInformation)
 {
     if (registrationInformation == null)
     {
         return(BadRequest());
     }
     return(Ok(Service.RegisterNewUser(registrationInformation)));
 }
 public ActionResult Edit([Bind(Include = "UserRoles,Email,UserName,Password,ConfirmPassword")] RegistrationInformation registrationInformation)
 {
     if (ModelState.IsValid)
     {
         db.Entry(registrationInformation).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(registrationInformation));
 }
Exemple #8
0
        public bool Add(RegistrationInformation registrationInformation)
        {
            SqlCommand command = new SqlCommand(@"INSERT INTO UserInformation values('" + registrationInformation.Username + "','" + registrationInformation.Password + "','" + registrationInformation.FirstName + "','" + registrationInformation.LastName + "','" + registrationInformation.Email + "')", connection);

            connection.Open();
            bool isAdded = command.ExecuteNonQuery() > 0;

            connection.Close();
            return(isAdded);
        }
Exemple #9
0
        public void HandleConnectionAsync_Successful_RegistersAndReads()
        {
            var registrationInfo = new RegistrationInformation {
                Nickname = "hax2themax"
            };

            _mockTcpClient.Setup(tcp => tcp.GetStream()).Returns(new MemoryStream());
            _mockClient.Setup(f => f.SendRegistrationInfoAsync(registrationInfo)).Returns(Task.Delay(0)).Verifiable();
            _mockClient.Setup(f => f.BeginReadAsync()).Verifiable();

            _client.HandleConnectionAsync(registrationInfo).Wait();
        }
        // GET: RegistrationInformation/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RegistrationInformation registrationInformation = db.RegistrationInformations.Find(id);

            if (registrationInformation == null)
            {
                return(HttpNotFound());
            }
            return(View(registrationInformation));
        }
        public ActionResult Register(RegistrationInformation registrationInformation)
        {
            if (ModelState.IsValid)
            {
                registrationInformation.UserType = "Admin";
                registrationInformation.Status   = "Active";

                db.RegistrationInformations.Add(registrationInformation);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(registrationInformation));
        }
        public override void RegisterOnPremise(RegistrationInformation registrationInformation)
        {
            CheckDisposed();

            UnregisterOnPremise(registrationInformation.ConnectionId);

            _logger.Debug("Registering OnPremise '{0}' via connection '{1}'", registrationInformation.OnPremiseId, registrationInformation.ConnectionId);

            var queue = DeclareOnPremiseQueue(registrationInformation.OnPremiseId);

            var consumer = _bus.Advanced.Consume(queue, (Action <IMessage <string>, MessageReceivedInfo>)((message, info) => registrationInformation.RequestAction(JsonConvert.DeserializeObject <OnPremiseConnectorRequest>(message.Body))));

            _onPremiseConsumers[registrationInformation.ConnectionId] = consumer;
            _onPremises[registrationInformation.ConnectionId]         = new ConnectionInformation(registrationInformation.OnPremiseId);
        }
        public RegistrationInformation GetRegistrationInformation(int idUser)
        {
            var personalInformation = new RegistrationInformation();

            personalInformation.User            = Context.Users.First(c => c.Id == idUser);
            personalInformation.Customer        = Context.Customers.First(c => c.Id == personalInformation.User.IdCustomer);
            personalInformation.PhysicalAddress = Context.Addresses.First(c => c.Id == personalInformation.Customer.IdAddress);
            var phoneNumbers = Context.PhoneNumbers.Where(c => c.IdCustomer == personalInformation.Customer.Id && c.IsActive);

            personalInformation.PhoneNumbers = new List <PhoneNumber>();
            foreach (var phoneNumber in phoneNumbers)
            {
                personalInformation.PhoneNumbers.Add(Context.PhoneNumbers.First(c => c.Id == phoneNumber.Id));
            }
            return(personalInformation);
        }
        internal RegistrationInformation GetPersonalInformationWithCustomerId(int idCustomer)
        {
            var personalInformation = new RegistrationInformation();

            personalInformation.Customer        = Context.Customers.FirstOrDefault(c => c.Id == idCustomer && c.IsActive);
            personalInformation.User            = new User();
            personalInformation.PhysicalAddress = Context.Addresses.First(c => c.Id == personalInformation.Customer.IdAddress && c.IsActive);
            var phoneNumbers = Context.PhoneNumbers.Where(c => c.IdCustomer == personalInformation.Customer.Id && c.IsActive);

            personalInformation.PhoneNumbers = new List <PhoneNumber>();
            foreach (var phoneNumber in phoneNumbers)
            {
                personalInformation.PhoneNumbers.Add(Context.PhoneNumbers.First(c => c.Id == phoneNumber.Id));
            }
            return(personalInformation);
        }
Exemple #15
0
        public static User Create(RegistrationInformation registrationInformation)
        {
            var normalizedUsername = UsernameNormalizer.Normalize(registrationInformation.Username);
            var salt               = CreateSalt();
            var saltBase64         = Convert.ToBase64String(salt);
            var passwordHash       = PasswordHasher.Hash(registrationInformation.Password, salt, PasswordHasher.RecommendedHashLength);
            var passwordHashBase64 = Convert.ToBase64String(passwordHash);

            return(new User(
                       normalizedUsername,
                       registrationInformation.FirstName,
                       registrationInformation.LastName,
                       registrationInformation.Email,
                       saltBase64,
                       passwordHashBase64,
                       new List <Role>()));
        }
Exemple #16
0
        public void ConnectAsync_Successful_ConnectsClientAndSetsProperties()
        {
            const string hostname = "localhost";
            const int    port     = 6667;
            const string nickname = "hax2themax";

            var serverInfo = new ServerInformation {
                HostName = hostname, Port = port
            };
            var registrationInfo = new RegistrationInformation {
                Nickname = nickname
            };

            _mockTcpClient.Setup(tcp => tcp.Connect(hostname, port)).Verifiable();

            _mockClient.Setup(f => f.HandleConnectionAsync(registrationInfo)).Returns(Task.Delay(0)).Verifiable();

            _client.ConnectAsync(serverInfo, registrationInfo).Wait();

            Assert.AreEqual(serverInfo, _client.ServerInformation);
            Assert.AreEqual(nickname, _client.Nickname);
        }
Exemple #17
0
        /// <summary>
        /// Prompts the user for all of the necessary user registration information.
        /// </summary>
        /// <returns>An object containing the information</returns>
        private static RegistrationInformation ReadUserRegistrationInfo()
        {
            Console.Write("Enter nickname: ");
            var nickname = Console.ReadLine();

            Console.Write("Enter username: "******"Enter real name: ");
            var realName = Console.ReadLine();

            Console.Write("Enter pass: ");
            var pass = Console.ReadLine();

            var info = new RegistrationInformation
            {
                Nickname = nickname,
                Password = pass,
                RealName = realName,
                Username = username
            };

            return(info);
        }
		/// <summary>
		/// Removes a previously registered file extension.
		/// </summary>
		/// <param name="info">Information about the extension to
		/// unregister. All properties of the information class must have
		/// been filled before passing to this function.</param>
		public static void Unregister(
			RegistrationInformation info )
		{
			// TODO.
			throw new Exception( "Not yet implemented." );
		}
		/// <summary>
		/// Registers the given extension with the given application.
		/// </summary>
		/// <param name="info">Information about the extension to
		/// register. All properties of the information class must have
		/// been filled before passing to this function.</param>
		public static void Register(
			RegistrationInformation info )
		{
			if ( info.Extension == null ||
				info.Extension.Length <= 0 )
			{
				throw new ArgumentException(
					Resources.Str_ZetaLib_Core_Common_Misc_FileExtensionRegistration_01,
					@"info.Extension" );
			}
			else if ( info.ClassName == null ||
				info.ClassName.Length <= 0 )
			{
				throw new ArgumentException(
					Resources.Str_ZetaLib_Core_Common_Misc_FileExtensionRegistration_02,
					@"info.ClassName" );
			}
			else if ( info.Description == null ||
				info.Description.Length <= 0 )
			{
				throw new ArgumentException(
					Resources.Str_ZetaLib_Core_Common_Misc_FileExtensionRegistration_03,
					@"info.Description" );
			}
			else if ( info.ApplicationFilePath == null ||
				info.ApplicationFilePath.Length <= 0 )
			{
				throw new ArgumentException(
					Resources.Str_ZetaLib_Core_Common_Misc_FileExtensionRegistration_04,
					@"info.ApplicationFilePath" );
			}
			else
			{
				// Everything passed correctly.

				// Add dot if missing.
				if ( info.Extension[0] != '.' )
				{
					info.Extension = '.' + info.Extension;
				}

				bool hasSomethingChanged = false;

				// Create a new registry key under HKEY_CLASSES_ROOT.
				if ( !new List<string>( Registry.ClassesRoot.GetSubKeyNames()
					).Contains( info.Extension ) )
				{
					hasSomethingChanged = true;
				}
				RegistryKey key = Registry.ClassesRoot.CreateSubKey(
					info.Extension );

				// Create a value for this key that contains the class name.
				if ( key.GetValue( null ) == null ||
					key.GetValue( null ).ToString() != info.ClassName )
				{
					hasSomethingChanged = true;
				}
				key.SetValue(
					null,
					info.ClassName );

				// Create a new key for the class name.
				if ( !new List<string>( Registry.ClassesRoot.GetSubKeyNames()
					).Contains( info.ClassName ) )
				{
					hasSomethingChanged = true;
				}
				key = Registry.ClassesRoot.CreateSubKey(
					info.ClassName + @"\Shell\Open\Command" );

				// Set its value to the command line.
				string s = string.Format(
					@"""{0}"" ""%1""",
					info.ApplicationFilePath );
				if ( key.GetValue( null ) == null ||
					key.GetValue( null ).ToString() != s )
				{
					hasSomethingChanged = true;
				}
				key.SetValue( null, s );

				// TODO: Use the description.

				// TODO: Optionally set an icon as described at
				// http://support.microsoft.com/kb/247529/.

				if ( hasSomethingChanged )
				{
					// Notify Windows that file associations have changed.
					SHChangeNotify(
						SHCNE_ASSOCCHANGED,
						SHCNF_IDLIST,
						0,
						0 );

					// Flush.
					lock ( typeLock )
					{
						cacheFor_IsFileExtensionRegistered.Clear();
					}
				}
			}
		}
Exemple #20
0
        public bool Add(RegistrationInformation registrationInformation)
        {
            bool isAdded = registerRepository.Add(registrationInformation);

            return(isAdded);
        }