Beispiel #1
0
        public async Task <IDataResult <IList <ReplenishmentDetailsDto> > > GetReplenishmentDetailsDtosAsync()
        {
            List <ReplenishmentDetailsDto> dtos = new List <ReplenishmentDetailsDto>();
            var replenishments = await _replenishmentDao.GetListAsync();

            foreach (var replenishment in replenishments)
            {
                var prodToReplenish = await _productDao.GetAsync(p => p.Id == replenishment.ProductToReplenishId);

                var replenishmentLocation = await _locationDao.GetAsync(l => l.Id == replenishment.LocationId);

                var replenishmentDetailsDto = new ReplenishmentDetailsDto
                {
                    Id                     = replenishment.Id,
                    Reference              = replenishment.Reference,
                    ProductToReplenishId   = prodToReplenish.Id,
                    ProductToReplenishName = prodToReplenish.Name,
                    LocationId             = replenishmentLocation.Id,
                    LocationName           = replenishmentLocation.Name,
                    OnHandQuantity         = replenishment.OnHandQuantity,
                    OrderQuantity          = replenishment.OrderQuantity,
                    Status                 = replenishment.Status
                };
                dtos.Add(replenishmentDetailsDto);
            }


            return(new SuccessDataResult <IList <ReplenishmentDetailsDto> >(dtos));
        }
Beispiel #2
0
        public IDataResult <ReplenishmentDetailsDto> GetReplenishmentDetailsDtoById(int replenishmentId)
        {
            var replenishment         = _replenishmentDao.Get(r => r.Id == replenishmentId);
            var prodToReplenish       = _productDao.Get(p => p.Id == replenishment.ProductToReplenishId);
            var replenishmentLocation = _locationDao.Get(l => l.Id == replenishment.LocationId);

            var replenishmentDetailsDto = new ReplenishmentDetailsDto
            {
                Id                     = replenishment.Id,
                Reference              = replenishment.Reference,
                ProductToReplenishId   = prodToReplenish.Id,
                ProductToReplenishName = prodToReplenish.Name,
                LocationId             = replenishmentLocation.Id,
                LocationName           = replenishmentLocation.Name,
                OnHandQuantity         = replenishment.OnHandQuantity,
                OrderQuantity          = replenishment.OrderQuantity,
                Status                 = replenishment.Status
            };

            return(new SuccessDataResult <ReplenishmentDetailsDto>(replenishmentDetailsDto));
        }