Esempio n. 1
0
        public void NewPractitionerRegistration()
        {
            //Created Successfully
            NewPractitionerViewModel vm = new NewPractitionerViewModel();
            TestHelper       helper     = new TestHelper();
            PractitionerData controller = new PractitionerData();


            vm.CompanyEmailAddress = helper.RandomString(50, false);
            vm.FirstName           = helper.RandomString(20, false);
            vm.LastName            = helper.RandomString(20, false);
            string rdmPassword = helper.RandomString(16, false);

            vm.Password    = rdmPassword;
            vm.Gender      = helper.RandomString(20, false);
            vm.DateOfBirth = DateTime.UtcNow;

            Array    values      = Enum.GetValues(typeof(State));
            Religion rdmReligion = (Religion)values.GetValue(helper.RandomNumber(0, 4));

            vm.Religion          = rdmReligion;
            vm.EmailAddress      = helper.RandomString(50, false);
            vm.OfficePhoneNumber = helper.RandomString(12, false);
            string hrdCodedCompanyId = "14694BBE-A650-EA11-B77B-28C2DDBBBA40";

            vm.CompanyId = Guid.Parse(hrdCodedCompanyId);
            vm.Role      = helper.RandomString(10, false);
            Specialist rdmSpecialist = (Specialist)values.GetValue(helper.RandomNumber(0, 24));

            vm.Specialist    = rdmSpecialist;
            vm.Qualification = String.Empty;
            vm.UserName      = helper.RandomString(15, false);

            NewPractitionerViewModel result = controller.CreatePractitioner(vm);

            Assert.AreNotEqual(Guid.Empty, result.AccId);
            Assert.IsNotNull(result.CompanyEmailAddress);
        }
Esempio n. 2
0
        public NewPractitionerViewModel PractitionerRegister(NewPractitionerViewModel vm)
        {
            NewPractitionerViewModel result = new NewPractitionerViewModel();

            try
            {
                var salt = HashingHelper.GenerateSalt();
                vm.Salt = salt;
                var hashedPassword = HashingHelper.ComputeHMAC_SHA256(Encoding.UTF8.GetBytes(vm.Password), vm.Salt);
                vm.Password = Convert.ToBase64String(hashedPassword);

                //Convert back aligned date time due to restsharp
                vm.DateOfBirth = vm.DateOfBirth.ToLocalTime();

                PractitionerData dataLayer = new PractitionerData();
                result = dataLayer.CreatePractitioner(vm);
            }
            catch (Exception err)
            {
                new LogHelper().LogMessage("PractitionerBusiness.PractitionerRegister : " + err);
            }

            return(result);
        }