public ActionResult BuyItem(int itemId)
        {
            int       characterId = Convert.ToInt32(SessionManager.GetCharacterId());
            Character character   = CharacterDAO.GetAllInformations(characterId);

            Item itemToBuy = ItemDAO.Get(itemId);

            if (character.Coins < itemToBuy.Price || character.Level < itemToBuy.RequiredLevel)
            {
                FlashMessage.Danger("Erro: ", "Você não possuí moedas suficientes para realizar a compra ou não tem level suficiente para adquirir o item");
                return(RedirectToAction("Market", "Home", null));
            }

            foreach (var itemInBag in character.Bag.ItemsInBag)
            {
                if (itemInBag.Item == null)
                {
                    character.Coins -= itemToBuy.Price;
                    itemInBag.Item   = itemToBuy;
                    CharacterDAO.Update(character);
                    return(RedirectToAction("Index", "Home", null));
                }
            }
            FlashMessage.Danger("Erro: ", "Você não possuí slots vazios na mochila para armazenar o item");
            return(RedirectToAction("Market", "Home", null));
        }
Exemple #2
0
        // item
        public override Task <ItemInfo> GetItem(KeyObject request, ServerCallContext context)
        {
            var itemId = request.Body;

            var response = new ItemInfo();
            var item     = _itemDao.Get(itemId);
            var barcodes = _itemBarcodeDao.GetItemBarcodesByItemId(itemId);
            var subs     = _itemSubDao.GetItemSubsByItemId(itemId);
            var packages = _itemPackageDao.GetItemPackagesByItemId(itemId);

            response.Item = _mapper.Map <ItemDTO>(item);
            response.Barcodes.AddRange(barcodes.Select(b => _mapper.Map <ItemBarcodeDTO>(b)));
            response.Packages.AddRange(packages.Select(p => _mapper.Map <ItemPackageDTO>(p)));
            response.Subs.AddRange(subs.Select(s => _mapper.Map <ItemSubDTO>(s)));

            return(Task.FromResult(response));
        }
Exemple #3
0
        public ActionResult Item(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            Item item = itemDAO.Get((int)id);

            if (item == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                return(View(item));
            }
        }
Exemple #4
0
 public DataTable Get(int tableID)
 {
     return(item.Get(tableID));
 }