public StockEntry ToStockEntry()
        {
            var stockEntry = new StockEntry
            {
                Id = Guid.NewGuid(),
                CreatedDate = DateTime.Now,
                ShiftId = this.ShiftId.GetValueOrDefault(),
                ProviderId = this.ProviderId.GetValueOrDefault(),
                Boxes = this.Boxes.GetValueOrDefault(),
                Maples = this.Maples.GetValueOrDefault(),
                Eggs = this.Eggs.GetValueOrDefault(),
                IsDeleted = false
            };

            if (stockEntry.ProviderId == Guid.Empty)
            {
                stockEntry.ProviderId = null;
            }
            else
            {
                stockEntry.ProviderId = this.ProviderId.GetValueOrDefault();
            }

            return stockEntry;
        }
Пример #2
0
        internal void UpdateStock(Guid depositId,Guid productId , int boxes, int mapples, int eggsUnit)
        {
            var stock = Uow.Stocks.Get(x => x.DepositId == depositId && x.ProductId == productId);

            if (stock == null)
            {
                throw new ApplicationException(
                    "Debe exister una entidad stock para el producto antes de actualizar el stock");
            }

            var stockEntry = new StockEntry();

            stockEntry.Id = Guid.NewGuid();
            stockEntry.StockId = productId;

            stockEntry.Boxes = boxes;
            stockEntry.Maples = mapples;
            stockEntry.Eggs = eggsUnit;
            stockEntry.CreatedDate = _clock.Now;
            stockEntry.ShiftId = Guid.Empty;
        }
Пример #3
0
        public void Create(StockEntry stockEntry, Guid depositId, Guid productId)
        {
            var stock = _stockService.GetExistStock(depositId, productId);
            if (stock == null)
            {
                var stockCreate = new Stock();
                stockCreate.Id = new Guid();
                stockCreate.ProductId = productId;
                stockCreate.DepositId = depositId;
                stockCreate.CreatedDate = DateTime.Now;
                stockCreate.IsDeleted = false;

                _stockService.Create(stockCreate);

                stockEntry.StockId = stockCreate.Id;
            }
            else
            {
                stockEntry.StockId = stock.Id;
            }

            this.Create(stockEntry);
        }
 public static CreateStockEntryModel FromClient(StockEntry stockEntry)
 {
     var form = Mapper.Map<StockEntry, CreateStockEntryModel>(stockEntry);
     return form;
 }
Пример #5
0
 public void Create(StockEntry stockEntry)
 {
     Uow.StockEntries.Add(stockEntry);
     Uow.Commit();
 }