Пример #1
0
        public async Task <UserCurrencyModel> GetUserCurrencyAsync(Guid userId, string currency)
        {
            UserCurrency userCurrency = await _userCurrencyRepository.GetCurrencyAsync(userId, currency);

            UserCurrencyModel result = new UserCurrencyModel(userCurrency.Currency, userCurrency.IsPrimary);

            return(result);
        }
Пример #2
0
        public async Task <UserCurrencyModel> SetUserPrimaryCurrencyAsync(Guid userId, string currency)
        {
            UserCurrency userCurrency = await _userCurrencyRepository.SetPrimaryAsync(userId, currency);

            await _unitOfWork.SaveChangesAsync();

            UserCurrencyModel result = new UserCurrencyModel(userCurrency.Currency, userCurrency.IsPrimary);

            return(result);
        }
Пример #3
0
        public async Task <ActionResult <UserCurrencyModel> > SetUserPrimaryCurrency(string currency)
        {
            UserViewModel user = await GetCurrentUserAsync();

            if (user == null)
            {
                return(HandleUserNotFoundResult());
            }

            UserCurrencyModel result = await _userCurrencyService.SetUserPrimaryCurrencyAsync(user.Id, currency);

            return(HandleResult(result));
        }
Пример #4
0
        public async Task <ActionResult <UserCurrencyModel> > AddUserCurrency([FromBody] UserCurrencyCreateModel createModel)
        {
            UserViewModel user = await GetCurrentUserAsync();

            if (user == null)
            {
                return(HandleUserNotFoundResult());
            }

            UserCurrencyModel result = await _userCurrencyService.AddUserCurrencyAsync(user.Id, createModel.Currency, createModel.IsPrimary);

            return(HandleResult(result));
        }
Пример #5
0
        public async Task <UserCurrencyModel> AddUserCurrencyAsync(Guid userId, string currency, bool isPrimary)
        {
            UserCurrency userCurrency = await _userCurrencyRepository.GetCurrencyAsync(userId, currency);

            if (userCurrency == null)
            {
                userCurrency = await _userCurrencyRepository.CreateAsync(userId, currency, isPrimary);

                await _unitOfWork.SaveChangesAsync();
            }

            UserCurrencyModel result = new UserCurrencyModel(userCurrency.Currency, userCurrency.IsPrimary);

            return(result);
        }