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); }
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); }
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)); }
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)); }
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); }