Beispiel #1
0
        public int AssignItemToStructures(ItemsStructuresListVM itemsStructuresListVM, string userName)
        {
            var itemStructures = new List <ItemStructure>();

            foreach (var i in itemsStructuresListVM.ItemStructures)
            {
                itemStructures.Add(new ItemStructure()
                {
                    ItemId       = i.ItemId,
                    StructureId  = i.StructureId,
                    ItemQuantity = i.ItemQtyForStructure
                });
            }

            var itemStructure = _itemStructureRepository.AddItemToStructures(itemStructures, itemsStructuresListVM.ItemId, userName);

            return(itemStructure);
        }
Beispiel #2
0
        public ItemsStructuresListVM GetItemsByStructure(int structureId, int pageSize, int pageNo, string searchString)
        {
            var itemsForStructure = _itemStructureRepository.GetAllStructures()
                                    .Where(s => s.StructureId == structureId);

            var itemsListVM = itemMapping.MapItemStructure(itemsForStructure);

            var itemsToShow = itemsListVM.Skip(pageSize * (pageNo - 1)).Take(pageSize);
            var itemsList   = new ItemsStructuresListVM()
            {
                PaggingInfo = new PagingInfo()
                {
                    CurrentPage = pageNo, ItemsPerPage = pageSize, TotalItems = itemsForStructure.Count()
                },
                ItemStructures = itemsToShow.ToList()
            };

            return(itemsList);
        }
Beispiel #3
0
        public ItemsStructuresListVM GetItemStructuresForAssign(int itemId)
        {
            var itemStructures       = _itemStructureRepository.GetAllStructures();
            var itemStructuresListVM = new ItemsStructuresListVM();

            itemStructuresListVM.ItemId         = itemId;
            itemStructuresListVM.ItemStructures = itemMapping.MapItemStructure(itemStructures);
            var itemStustureQty = _itemStructureRepository.GetAllItemStructuresByItemId(itemId);

            foreach (var istr in itemStustureQty)
            {
                if (istr.ItemQuantity > 0)
                {
                    itemStructuresListVM.ItemStructures
                    .FirstOrDefault(x => x.StructureId == istr.StructureId && x.ItemId == istr.ItemId)
                    .ItemQtyForStructure = istr.ItemQuantity;
                }
            }
            return(itemStructuresListVM);
        }
Beispiel #4
0
        public IActionResult AssignItemToStructures(ItemsStructuresListVM itemsStructuresListVM, int itemId)
        {
            var assignToStructures = _itemService.AssignItemToStructures(itemsStructuresListVM, User.Identity.Name);

            return(RedirectToAction("ItemDetails", new { id = assignToStructures }));
        }