public void UpdateAdvertiserData(int id, SaveAdvertiserMessage message)
        {
            var advertiser = _advertiserRepository.Get(id);

            advertiser.Email    = message.Email;
            advertiser.Name     = message.Name;
            advertiser.Password = _cryptographyService.Encrypt(message.Password);
        }
示例#2
0
        public Task UpdateAsync(Advertiser user)
        {
            var updatedUser = _advertiserRepository.Get(user.Id);

            updatedUser.Email    = user.Email;
            updatedUser.Name     = user.Name;
            updatedUser.UserName = user.UserName;
            return(_advertiserRepository.SaveChangesAsync());
        }
示例#3
0
        public async Task <AuthenticateResponse> AuthenticateAdvertiser(AuthenticateRequest request)
        {
            var errors = request.Validate();

            if (errors.Any())
            {
                throw new ValidationException(errors);
            }

            var user = _advertiserRepository.Get(request.Username);

            if (user == null)
            {
                throw new Exception("Usuário não encontrado");
            }

            _authenticationService.AuthenticateAdvertiser(request);
            await _signInService.SignInAdvertiserAsync(user, true);

            return(new AuthenticateResponse {
                ReturnUrl = request.ReturnUrl ?? "/Advertiser/Home/Index"
            });
        }
示例#4
0
        public void Create(CreateServiceSolicitationMessage message)
        {
            var serviceSolicitation = new ServiceSolicitation();

            serviceSolicitation.Location      = _locationRepository.Get(message.LocationId);
            serviceSolicitation.Advertiser    = _advertiserRepository.Get(message.AdvertiserId);
            serviceSolicitation.EndDate       = message.EndDate;
            serviceSolicitation.ContractModel = _contractModelRepository.Get(message.ContractModelId);
            serviceSolicitation.MonthlyValue  = serviceSolicitation.Location.MonthlyValue;
            serviceSolicitation.StartDate     = message.StartDate;

            _serviceSolicitationRepository.Add(serviceSolicitation);
            _serviceSolicitationRepository.SaveChanges();
        }
        public IPrincipal AuthenticateAdvertiser(AuthenticateMessage message)
        {
            var advertiser = _advertiserRepository.Get(message.Username);

            if (advertiser == null)
            {
                throw new InvalidUsernameException();
            }

            var encryptedProvidedPassword = _cryptographyService.Encrypt(message.Password);

            if (!advertiser.Password.Equals(encryptedProvidedPassword))
            {
                throw new InvalidPasswordException();
            }

            return(Authenticate(AUTHENTICATION_TYPE_ADVERTISER));
        }