Ejemplo n.º 1
0
 public WarehouseController(
     IWarehouseRepository warehouseRepository,
     WarehouseMapper warehouseMapper)
 {
     _warehouseRepository = warehouseRepository;
     _warehouseMapper     = warehouseMapper;
 }
        async Task IDataService.SaveWarehouseItemAsync(IWarehouseItem item)
        {
            var dto = WarehouseMapper.MapToWarehouseDto(item);

            if (item.IsNew)
            {
                await ServiceRunner.RunAsync(() => _warehouseProvider.CreateWarehouseItem(dto));
            }
            else
            {
                await ServiceRunner.RunAsync(() => _warehouseProvider.UpdateWarehouseItem(dto));
            }
        }
Ejemplo n.º 3
0
 public DataService(IWarehouseProvider warehouseProvider, WarehouseMapper warehouseMapper)
 {
     _warehouseProvider = warehouseProvider;
     _warehouseMapper   = warehouseMapper;
 }
Ejemplo n.º 4
0
        private void CheckForNecessaryShifts(ComplaintDocument document, IEnumerable <ComplaintDecision> decisions)
        {
            //List<Allocation> necessaryShifts = new List<Allocation>();
            AllocationCollection necessaryAllocations = new AllocationCollection();

            foreach (var decision in decisions)
            {
                Warehouse wh = DictionaryMapper.Instance.GetWarehouse(decision.WarehouseId.Value);

                if (wh.ValuationMethod == ValuationMethod.DeliverySelection)
                {
                    var allocation = necessaryAllocations.Allocations.Where(s => s.ItemId == decision.ReplacementItemId && s.WarehouseId == decision.WarehouseId.Value).FirstOrDefault();

                    //jezeli mamy juz taki shift potrzebny to tylko zwiekszamy ilosc, jesli nie to tworzymy go nowego
                    if (allocation == null)
                    {
                        allocation = new Allocation()
                        {
                            ItemId = decision.ReplacementItemId, WarehouseId = decision.WarehouseId.Value
                        };
                        necessaryAllocations.Allocations.Add(allocation);
                    }

                    allocation.FirstAllocation().Quantity += decision.Quantity;
                }
            }

            bool throwException = false;

            /* sprawdzamy czy na dokumencie wybrano dostawy
             * jezeli wybrano jakies to sprawdzamy czy w wystarczajacych ilosciach
             * jezeli nie wybrano to uzupelniamy je domyslnymi dostawami i rzucamy
             * w postaci wyjatku do panelu
             */

            if (document.AllocationCollection != null) //sprawdzamy czy ilosci starczy
            {
                foreach (var necessaryAllocation in necessaryAllocations.Allocations)
                {
                    var clientAllocation = document.AllocationCollection.Allocations.Where(s => s.ItemId == necessaryAllocation.ItemId && s.WarehouseId == necessaryAllocation.WarehouseId).FirstOrDefault();

                    if (clientAllocation == null || //jezeli w ogole nie wybral alokacji dla tej pary item/warehouse
                        clientAllocation.AllocationShifts.Sum(i => i.Quantity) < necessaryAllocation.FirstAllocation().Quantity || //jezeli wybral za malo
                        clientAllocation.AllocationShifts.Where(x => x.IncomeWarehouseDocumentLineId == Guid.Empty).FirstOrDefault() != null)    //jezeli nie wskazal z jakiej linii pz pochodzi
                    {
                        throwException = true;
                        break;
                    }
                }
            }
            else if (necessaryAllocations.Allocations.Count > 0)
            {
                throwException = true;
            }

            if (throwException)
            {
                //teraz uzupelniamy domyslne transze i kopiujemy je do nowej kolekcji (bo starej nie mozemy zmieniac jak bedziemy iterowac po niej)
                AllocationCollection allocations = new AllocationCollection();
                WarehouseMapper      whMapper    = DependencyContainerManager.Container.Get <WarehouseMapper>();

                foreach (var allocation in necessaryAllocations.Allocations)
                {
                    XElement xml    = whMapper.GetAvailableLots(allocation.ItemId, allocation.WarehouseId);
                    XElement ptrLot = (XElement)xml.FirstNode;

                    //w tej petli nie zmieniamy wartosci co sa w xmlu xml bo i tak
                    //kazdy towar jest przerwazany tylko raz (w postaci zagregowanej)
                    while (allocation.FirstAllocation().Quantity > 0 && ptrLot != null)
                    {
                        var newAllocation = allocations.Get(allocation.ItemId, allocation.WarehouseId);

                        newAllocation.ItemName = DependencyContainerManager.Container.Get <ItemMapper>().GetItemName(newAllocation.ItemId);

                        var newAllocationItem = new AllocationShift();
                        newAllocation.AllocationShifts.Add(newAllocationItem);

                        if (ptrLot.Attribute("shiftId") != null)
                        {
                            newAllocationItem.SourceShiftId = new Guid(ptrLot.Attribute("shiftId").Value);
                        }

                        newAllocationItem.IncomeWarehouseDocumentLineId = new Guid(ptrLot.Attribute("incomeWarehouseDocumentLineId").Value);

                        if (ptrLot.Attribute("containerLabel") != null)
                        {
                            newAllocationItem.ContainerLabel = ptrLot.Attribute("containerLabel").Value;
                        }

                        if (ptrLot.Attribute("slotContainerLabel") != null)
                        {
                            newAllocationItem.SlotContainerLabel = ptrLot.Attribute("slotContainerLabel").Value;
                        }

                        decimal lotQuantity = Convert.ToDecimal(ptrLot.Attribute("quantity").Value, CultureInfo.InvariantCulture);

                        if (lotQuantity >= allocation.FirstAllocation().Quantity) //jest wiecej niz potrzebujemy
                        {
                            newAllocationItem.Quantity = allocation.FirstAllocation().Quantity;
                            allocation.FirstAllocation().Quantity = 0;
                        }
                        else
                        {
                            newAllocationItem.Quantity = lotQuantity;
                            allocation.FirstAllocation().Quantity -= lotQuantity;
                        }

                        ptrLot = (XElement)ptrLot.NextNode;
                    }

                    if (allocation.FirstAllocation().Quantity != 0)
                    {
                        string itemName      = DependencyContainerManager.Container.Get <ItemMapper>().GetItemName(allocation.ItemId);
                        string warehouseName = DictionaryMapper.Instance.GetWarehouse(allocation.WarehouseId).Symbol;
                        throw new ClientException(ClientExceptionId.NoItemInStock, null, "itemName:" + itemName, "warehouseName:" + warehouseName);
                    }
                }

                XElement xmlData = allocations.Serialize();
                throw new ClientException(ClientExceptionId.SelectLots)
                      {
                          XmlData = xmlData
                      };
            }
        }
Ejemplo n.º 5
0
 public ItemInWarehousesController(IAppBLL bll)
 {
     _bll             = bll;
     _warehouseMapper = new WarehouseMapper();
 }
Ejemplo n.º 6
0
        public async Task <IActionResult> Put(Guid id, [FromBody] WarehouseItemDto warehouseItem)
        {
            await _warehouseRepository.Update(WarehouseMapper.MapToWarehouseItem(warehouseItem));

            return(Ok());
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> Post([FromBody] WarehouseItemDto warehouseItem)
        {
            await _warehouseRepository.Add(WarehouseMapper.MapToWarehouseItem(warehouseItem));

            return(Ok());
        }
Ejemplo n.º 8
0
 public WarehousesController(IAppBLL bll)
 {
     _bll             = bll;
     _warehouseMapper = new WarehouseMapper();
     _itemMapper      = new ItemMapper();
 }
 public WarehouseService(IUnitOfWork context)
 {
     Context         = context;
     WarehouseMapper = new WarehouseMapper();
 }