Exemplo n.º 1
0
        public override void MoveNext()
        {
            if (Validate())
            {
                Profile = ClientProfileDTO.CreateFromView(this);
                var json = JsonConvert.SerializeObject(Profile);
                _settings.AddOrUpdateValue(GetType().Name, json);

                var indexId = null != IndexClientDTO?IndexClientDTO.Id.ToString() : string.Empty;

                if (MoveNextLabel == "SAVE" || null != Profile.PreventEnroll && Profile.PreventEnroll.Value)
                {
                    Save();
                }
                else
                {
                    ShowViewModel <ClientEnrollmentViewModel>(new { clientinfo = ClientInfo, indexId = indexId });
                }
            }
            else
            {
                if (null != Errors && Errors.Any())
                {
                    _dialogService.ShowErrorToast(Errors.First().Value);
                }
            }
        }
Exemplo n.º 2
0
        public void SetUp()
        {
            _client = TestHelpers.CreateTestClients().First();

            _demographicDTO = JsonConvert.DeserializeObject <ClientDemographicDTO>(GetJson("d"));
            _addressDTO     = JsonConvert.DeserializeObject <ClientContactAddressDTO>(GetJson("c"));
            _profileDTO     = JsonConvert.DeserializeObject <ClientProfileDTO>(GetJson("p"));
            _enrollmentDTO  = JsonConvert.DeserializeObject <ClientEnrollmentDTO>(GetJson("e"));

            _clientRegistrationDTO = new ClientRegistrationDTO(_demographicDTO, _addressDTO, _profileDTO, _enrollmentDTO);
        }
Exemplo n.º 3
0
        public async Task <ClaimsIdentity> AuthenticateAsync(ClientProfileDTO client)
        {
            ClaimsIdentity  claims = null;
            ApplicationUser user   = await _Unit.Identity.UserManager.FindAsync(client.Email, client.Password);

            if (user != null)
            {
                claims = await _Unit.Identity.UserManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie);
            }
            return(claims);
        }
Exemplo n.º 4
0
        public async Task <OperationDetails> CreateAsync(ClientProfileDTO client)
        {
            ApplicationUser user = await _Unit.Identity.UserManager.FindByEmailAsync(client.Email);

            if (user == null)
            {
                user = new ApplicationUser()
                {
                    UserName = client.Email, Email = client.Email
                };
                var result = await _Unit.Identity.UserManager.CreateAsync(user, client.Password);

                if (result.Errors.Count() > 0)
                {
                    return(new OperationDetails(false, result.Errors.FirstOrDefault(), ""));
                }
                var role = await _Unit.Identity.RoleManager.FindByNameAsync(client.Role);

                if (role == null)
                {
                    role = new ApplicationRole {
                        Name = client.Role
                    };
                    await _Unit.Identity.RoleManager.CreateAsync(role);
                }
                await _Unit.Identity.UserManager.AddToRoleAsync(user.Id, client.Role);

                ClientProfile profile = new ClientProfile()
                {
                    Id = user.Id, Name = client.Name
                };
                _Unit.Identity.ClientManager.Create(profile);
                return(new OperationDetails(true, "", ""));
            }
            else
            {
                return(new OperationDetails(false, "Пользователь с таким логином уже существует", "Email"));
            }
        }