public async Task <IDataResult <TokenModel> > SignInAsync(SignInModel signInModel)
        {
            var validation = new SignInModelValidator().Validate(signInModel);

            if (validation.Failed)
            {
                return(DataResult <TokenModel> .Fail(validation.Message));
            }

            var signedInModel = await _userRepository.SignInAsync(signInModel);

            validation = _signInService.Validate(signedInModel, signInModel);

            if (validation.Failed)
            {
                return(DataResult <TokenModel> .Fail(validation.Message));
            }

            var userLogModel = UserLogFactory.Create(signedInModel);

            await _userLogApplicationService.AddAsync(userLogModel);

            var tokenModel = _signInService.CreateToken(signedInModel);

            return(DataResult <TokenModel> .Success(tokenModel));
        }
Пример #2
0
        public async Task AddAsync(UserLogModel userLogModel)
        {
            var userLogEntity = UserLogFactory.Create(userLogModel);

            await _userLogRepository.AddAsync(userLogEntity);

            await _unitOfWork.SaveChangesAsync();
        }
        public async Task <IResult> AddAsync(UserLogModel userLogModel)
        {
            var validation = new UserLogModelValidator().Validate(userLogModel);

            if (validation.Failed)
            {
                return(Result.Fail(validation.Message));
            }

            var userLogEntity = UserLogFactory.Create(userLogModel);

            await _userLogRepository.AddAsync(userLogEntity);

            await _unitOfWork.SaveChangesAsync();

            return(Result.Success());
        }
        public async Task SignOutAsync(SignOutModel signOutModel)
        {
            var userLogModel = UserLogFactory.Create(signOutModel);

            await _userLogApplicationService.AddAsync(userLogModel);
        }