Exemple #1
0
        // POST api/<controller>
        public async Task <string> Post(DriverModel value)
        {
            string                result   = "Ok";
            PasswordHasher        ph       = new PasswordHasher();
            var                   passHash = ph.HashPassword(value.Password);
            NHibernateDriverStore hds      = new NHibernateDriverStore();
            var                   driver   = new DriverModel {
                Email         = value.Email,
                FirstName     = value.FirstName,
                LastName      = value.LastName,
                MiddleName    = value.MiddleName,
                BirthDate     = value.BirthDate,
                Gender        = value.Gender,
                HomeAddress   = value.HomeAddress,
                Town          = value.Town,
                District      = value.District,
                Province      = value.Province,
                City          = value.City,
                MobileNumber  = value.MobileNumber,
                LicenseNumber = value.LicenseNumber,
                Password      = passHash,
                Status        = RegistrationStatus.ForValidation
            };

            try {
                await hds.CreateDriverAsync(driver);

                var nhus   = new NHibernateUserStore();
                var emails = await nhus.GetAllAdminEmailAsync();

                await Emailer.SendMessage(driver.Email + " For Activation", emails, "Registration");
            } catch (Exception e) {
                result = e.Message;
            }
            return(result);
        }