Example #1
0
        public async Task <Item> InsertAsync(ItemInput input)
        {
            if (string.IsNullOrEmpty(input.Description))
            {
                throw new ArgumentNullException("Descrição do produto é obrigatório!!");
            }

            if (input.Ammount <= 0)
            {
                throw new ArgumentNullException("Quantidade de estoque necessita ser maior que zero");
            }

            var item = new Item(input.Description, input.Price);

            await _itemRepository
            .InsertAsync(item)
            .ConfigureAwait(false);

            var stock = new Stock(item.Id, input.Ammount);

            await _stockRepository
            .InsertAsync(stock)
            .ConfigureAwait(false);

            return(item);
        }
Example #2
0
    /*  protected void SlotCraftTransfer(ItemInput droppedItem, SlotInput otherSlot, Dictionary<string, Item> InventoryAdd, int numSlots,
     * List<GameObject> slotsContainer, List<GameObject> itemsContainer, Dictionary<string, Item> InventoryRemove) {
     *  Item it = otherSlot.StoredItem;
     *  var type = it.GetType();
     *  var obj = (Item)Activator.CreateInstance(type, it);
     *  obj.ActiveContainer = null;
     *  obj.SetQuantity(1);
     *  Pd.AddItem(
     *      obj,
     *      InventoryAdd,
     *      numSlots,
     *      slotsContainer,
     *      itemsContainer,
     *      true
     *      );
     *  Pd.RemoveItem(it, 1, InventoryRemove);
     * }*/

    protected void SlotToSlot(ItemInput droppedItem, SlotContainer otherSlot)
    {
        //Transferring the item (if it exists) from this slot to the other
        if (this.CurrentItem != null)
        {
            Item       incomingItem          = otherSlot.CurrentItem;
            GameObject incomingItemContainer = otherSlot.ItemContainer;
            int        incomingItemSlot      = incomingItem.Slot;
            GameObject incomingSlotParent    = incomingItemContainer.GetComponent <ItemInput>().SlotParent;

            Item       thisItem          = CurrentItem;
            GameObject thisItemContainer = ItemContainer;
            int        thisSlot          = thisItem.Slot;
            GameObject thisSlotParent    = thisItemContainer.GetComponent <ItemInput>().SlotParent;

            otherSlot.CurrentItem      = thisItem;
            otherSlot.CurrentItem.Slot = thisSlot;
            thisItemContainer.GetComponent <ItemInput>().SlotParent     = incomingSlotParent;
            incomingItemContainer.GetComponent <ItemInput>().SlotParent = thisSlotParent;
            this.CurrentItem      = incomingItem;
            this.CurrentItem.Slot = incomingItemSlot;
        }
        else
        {
            otherSlot.CurrentItem.Slot = Pd.SlotContainers.IndexOf(this);
            this.CurrentItem           = otherSlot.CurrentItem;
            droppedItem.SlotParent     = this.gameObject;
            this.ItemContainer         = otherSlot.ItemContainer;
            otherSlot.CurrentItem      = null;
            otherSlot.ItemContainer    = null;
        }
    }
Example #3
0
        public async Task <Item> Add(ItemInput item)
        {
            var entity = mapper.MapItem(item, new ItemEntity());

            this.dbContext.Add(entity);
            await SaveChanges();

            return(mapper.MapItem(entity, new Item()));
        }
Example #4
0
        public void Run(ItemInput input = null)
        {
            ItemInOutput context = input;

            foreach (var wi in workflowList)
            {
                context = wi.Invoke(context);
            }
        }
Example #5
0
        public async Task <IActionResult> Post([FromBody] ItemInput input)
        {
            try
            {
                await _itemAppService.InsertAsync(input);

                return(Created("", ""));
            }
            catch (Exception ex)
            {
                return(BadRequest($"Erro => {ex.Message}"));
            }
        }
Example #6
0
        public async Task <Item> Update(Guid itemId, ItemInput item)
        {
            var entity = await this.Entity(itemId);

            if (entity != null)
            {
                mapper.MapItem(item, entity);
                await SaveChanges();

                return(mapper.MapItem(entity, new Item()));
            }
            throw new KeyNotFoundException($"Cannot find item {itemId.ToString()}");
        }
Example #7
0
        private void ReturnGoods_Load(object sender, EventArgs e)
        {
            ItemInput itemInput = new ItemInput(this, log);

            itemInput.TopLevel = false;
            this.itemInputPanel.Controls.Add(itemInput);
            itemInput.Show();

            Times times = new Times();

            times.TopLevel = false;
            this.timePanel.Controls.Add(times);
            times.Show();
        }
        public ActionResult Create(ItemInput input)
        {
            var userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;

            var item = new Item
            {
                UserId      = userId,
                Title       = input.Title,
                Description = input.Description,
                IsDone      = input.IsDone
            };

            item.Id = _itemService.Create(item);
            return(CreatedAtRoute("GetItem", new { id = item.Id }, item));
        }
    public void OnDrop(PointerEventData eventData)
    {
        if (PlayerData.Slots[SlotID] == null)
        {
            return;
        }
        ItemInput droppedItem = eventData.pointerDrag.GetComponent <ItemInput>();
        SlotInput otherSlot   = droppedItem.GetComponent <ItemInput>().OriginalParent.GetComponent <SlotInput>();

        if (otherSlot == this || IsLocked || otherSlot.IsLocked)
        {
            return;
        }
        Debug.Assert(PlayerData.Slots[SlotID].transform.childCount == 0 || PlayerData.Slots[SlotID].transform.childCount == 1);
        if (!CraftingSlot && !otherSlot.CraftingSlot && !IsStructureSlot && !otherSlot.IsStructureSlot ||
            CraftingSlot && otherSlot.CraftingSlot ||
            IsStructureSlot && otherSlot.IsStructureSlot)
        {
            SlotToSlot(droppedItem, otherSlot);
        }
        else if (CraftingSlot && !otherSlot.CraftingSlot && !otherSlot.IsStructureSlot)
        {
            SlotCraftTransfer(droppedItem, otherSlot, PlayerData.CraftingInventory, PlayerData.NumCraftingSlots,
                              PlayerData.CraftingSlots, PlayerData.CraftingItems, Pd.GetInventory());
        }
        else if (!CraftingSlot && otherSlot.CraftingSlot && !otherSlot.IsStructureSlot)
        {
            SlotCraftTransfer(droppedItem, otherSlot, Pd.GetInventory(), PlayerData.NumItemSlots,
                              PlayerData.Slots, PlayerData.Items, PlayerData.CraftingInventory);
        }
        else if (Pd.CurrentTile.Structure.Value != null)
        {
            Dictionary <String, Item> structureInventory = Pd.CurrentTile.Structure.Value.GetComponent <StructureData>().Inventory;
            List <GameObject>         itContainer        = Pd.CurrentTile.Structure.Value.GetComponent <StructureData>().ItemContainer;
            if (IsStructureSlot && !otherSlot.IsStructureSlot)
            {
                SlotStructureTransfer(droppedItem, otherSlot, structureInventory, PlayerData.NumStructSlots, PlayerData.StructureSlots, itContainer, Pd.GetInventory());
            }
            else if (!IsStructureSlot && otherSlot.IsStructureSlot)
            {
                SlotStructureTransfer(droppedItem, otherSlot, Pd.GetInventory(), PlayerData.NumItemSlots, PlayerData.Slots, PlayerData.Items, structureInventory);
            }
        }
    }
    protected void SlotCraftTransfer(ItemInput droppedItem, SlotInput otherSlot, Dictionary <string, Item> InventoryAdd, int numSlots,
                                     List <GameObject> slotsContainer, List <GameObject> itemsContainer, Dictionary <string, Item> InventoryRemove)
    {
        Item it   = otherSlot.StoredItem;
        var  type = it.GetType();
        var  obj  = (Item)Activator.CreateInstance(type, it);

        obj.ActiveContainer = null;
        obj.SetQuantity(1);
        Pd.AddItem(
            obj,
            InventoryAdd,
            numSlots,
            slotsContainer,
            itemsContainer,
            true
            );
        Pd.RemoveItem(it, 1, InventoryRemove);
    }
 protected void SlotToSlot(ItemInput droppedItem, SlotInput otherSlot)
 {
     if (PlayerData.Slots[this.SlotID].transform.childCount == 1)
     {
         otherSlot.StoredItem      = this.StoredItem;
         otherSlot.StoredItem.Slot = otherSlot.SlotID;
         GameObject thisItem = PlayerData.Slots[this.SlotID].GetComponentInChildren <ItemInput>().gameObject;
         thisItem.transform.SetParent(otherSlot.transform);
         thisItem.transform.localPosition = Vector2.zero;
     }
     else
     {
         otherSlot.StoredItem.Slot = this.SlotID;
         otherSlot.StoredItem      = null;
     }
     droppedItem.transform.SetParent(this.transform);
     droppedItem.transform.localPosition = Vector2.zero;
     this.StoredItem      = droppedItem.GetComponent <ItemInput>().Item;
     this.StoredItem.Slot = this.SlotID;
 }
Example #12
0
    public void OnDrop(PointerEventData eventData)
    {
        ItemInput     droppedItem = eventData.pointerDrag.GetComponent <ItemInput>();
        SlotContainer otherSlot   = droppedItem.GetComponent <ItemInput>().SlotParent.GetComponent <SlotContainer>();

        if (otherSlot == this)
        {
            return;
        }
        //if (!CraftingSlot && !otherSlot.CraftingSlot || CraftingSlot && otherSlot.CraftingSlot) {
        SlotToSlot(droppedItem, otherSlot);

        /*} else if (CraftingSlot && !otherSlot.CraftingSlot) {
         *  SlotCraftTransfer(droppedItem, otherSlot, PlayerData.CraftingInventory, PlayerData.NumCraftingSlots,
         *      PlayerData.CraftingSlots, PlayerData.CraftingItems, Pd.GetInventory());
         * } else {
         *  SlotCraftTransfer(droppedItem, otherSlot, Pd.GetInventory(), PlayerData.NumItemSlots,
         *      PlayerData.Slots, PlayerData.Items, PlayerData.CraftingInventory);
         * }
         */
    }
    protected void SlotStructureTransfer(ItemInput droppedItem, SlotInput otherSlot, Dictionary <string, Item> InventoryAdd, int numSlots,
                                         List <GameObject> slotsContainer, List <GameObject> itemsContainer, Dictionary <string, Item> InventoryRemove)
    {
        SlotCraftTransfer(droppedItem, otherSlot, InventoryAdd, numSlots,
                          slotsContainer, itemsContainer, InventoryRemove);
        //Granary
        if (Pd.CurrentTile.Structure.Value.GetComponent <StructureData>() is GranaryData &&
            InventoryRemove == Pd.GetInventory())
        {
            GranaryData gD = (GranaryData)Pd.CurrentTile.Structure.Value.GetComponent <StructureData>();

            /*foreach (GameObject g in itemsContainer) {
             *  if (g.gameObject == null) {
             *      itemsContainer.Remove(g);
             *  }
             * }*/
            GameObject asdf = itemsContainer.Find(g => g.gameObject && g.GetComponent <ItemInput>().Item.GetName().Equals(droppedItem.Item.GetName()));
            if (!(asdf.GetComponent <ItemInput>().Item is Food))
            {
                return;
            }
            gD.StartCoroutine(gD.MutliplyItem(asdf.gameObject.transform.parent.GetComponent <SlotInput>()));
        }
        //Torch
        if (!(Pd.CurrentTile.Structure.Value.GetComponent <StructureData>() is GranaryData) &&
            InventoryRemove == Pd.GetInventory() && droppedItem.Item.GetName().Equals(Global.ItemNames[ItemList.Torch]))
        {
            Pd.FOWStructures.Add(Pd.CurrentTile.Structure.Value);
            Debug.Log("hello");
        }
        else if (!(Pd.CurrentTile.Structure.Value.GetComponent <StructureData>() is GranaryData) &&
                 !(InventoryRemove == Pd.GetInventory()) && droppedItem.Item.GetName().Equals(Global.ItemNames[ItemList.Torch]))
        {
            Pd.FOWStructures.Remove(Pd.CurrentTile.Structure.Value);
        }
    }
Example #14
0
 public async Task <Item> Update(Guid itemId, [FromBody] ItemInput item)
 {
     return(await repo.Update(itemId, item));
 }
Example #15
0
 public async Task <Item> Add([FromBody] ItemInput item)
 {
     return(await repo.Add(item));
 }
Example #16
0
 public ItemEntity MapItem(ItemInput src, ItemEntity dest)
 {
     return(mapper.Map(src, dest));
 }