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

            if (validation.IsError)
            {
                return(DataResult <TokenModel> .Error(validation.Message));
            }

            var signedInModel = await UserRepository.SignInAsync(signInModel);

            validation = SignInService.Validate(signedInModel, signInModel);

            if (validation.IsError)
            {
                return(DataResult <TokenModel> .Error(validation.Message));
            }

            var userLogModel = new UserLogModel(signedInModel.UserId, LogType.SignIn);

            await UserLogApplicationService.AddAsync(userLogModel);

            await UnitOfWork.SaveChangesAsync();

            var tokenModel = SignInService.CreateToken(signedInModel);

            return(DataResult <TokenModel> .Success(tokenModel));
        }
Beispiel #2
0
        public async Task SignOutAsync(SignOutModel signOutModel)
        {
            var userLogModel = new UserLogModel(signOutModel.UserId, LogType.SignOut);

            await UserLogApplicationService.AddAsync(userLogModel);

            await UnitOfWork.SaveChangesAsync();
        }