Example #1
0
        public async Task <string> BuyEquipmentForUser(ApiEquipment equipment, string userName)
        {
            var account = await _accountRepository.getUserByUsername(userName);

            if (account.AccountStatistics.Gold < equipment.Cost)
            {
                return("Insufficient gold!");
            }
            Equipment equip = await GetEquipmentFromDB(equipment);

            EquipmentOwned equipOwned = CreateEquipmentForAccount(userName, equip);
            await _equipmentRepository.BuyEquipmentForAccount(equipOwned);

            return("Equipment successfully added to your collection!");
        }