Beispiel #1
0
        public Task SendClientActivationEmailAsync(DomainPendingClient client)
        {
            if (string.IsNullOrEmpty(client.Email))
            {
                return(Task.FromResult(0));
            }

            var email = new SendEmailDomain
            {
                Address     = _settings.EmailAddressAlerts,
                DisplayName = Emails.SenderDisplayName,
                Emails      = new List <string> {
                    client.Email
                },
                Subject = Emails.SubjectRegistration,
                Body    = string.Format(
                    PortalResources.ClientActivation,
                    client.ContactPerson,
                    client.Email,
                    _settings.PortalUri,
                    client.Id)
            };

            // Send email on user registration
            return(_emailSenderService.SendEmailAsync(email));
        }
        public async Task <HttpResponseMessage> Post(RegisterClientModel model)
        {
            // Check whether user with same e-mail already exists
            DomainUser user = null;

            try
            {
                user = await _userService.FindByEmailAsync(model.Email);
            }
            catch (NotFoundException)
            {
            }

            if (user != null)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.Conflict, ResponseMessages.EntityAlreadyExists));
            }

            // Add pending client
            DomainPendingClient client = await _pendingClientService.AddAsync(model);

            // Send activation e-mail
            try
            {
                await _emailNotificationService.SendClientActivationEmailAsync(client);
            }
            catch (Exception e)
            {
                Trace.TraceError("Failed to send registration e-mail to client {0}: {1}", client.Id, e);
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Beispiel #3
0
        public async Task <DomainPendingClient> AddAsync(DomainPendingClient client)
        {
            PendingClientEntity entity = _mapper.Map <DomainPendingClient, PendingClientEntity>(client);

            entity.Created      = DateTime.UtcNow;
            entity.PasswordSalt = _cryptoService.GenerateSalt();
            entity.Password     = _cryptoService.EncodePassword(entity.Password, entity.PasswordSalt);

            entity = await _pendingClientRepository.AddAsync(entity);

            entity.Id = _stringEncryptor.EncryptString(entity.Id);

            return(_mapper.Map <PendingClientEntity, DomainPendingClient>(entity));
        }