Beispiel #1
0
        public async Task <IActionResult> Add(GoodInputModel model)
        {
            // TODO: Authentication and Authorization
            var goodId = await this.goodsService.AddAsync(model);

            return(this.Redirect("All"));
        }
        public async Task <int> AddAsync(GoodInputModel inputModel)
        {
            var warehouse = await this.warehousesRepository
                            .All()
                            .FirstOrDefaultAsync(x => x.Name == "Warehouse 1");

            var good = new Good()
            {
                SKU           = inputModel.SKU,
                Barcode       = inputModel.Barcode,
                Name          = inputModel.Name,
                DeliveryPrice = inputModel.DeliveryPrice,
                SalePrice     = inputModel.SalePrice,
                Quantity      = inputModel.Quantity,
                MeasureId     = inputModel.MeasureId,
                WarehouseId   = warehouse.Id,
            };

            await this.goodsRepository.AddAsync(good);

            await this.goodsRepository.SaveChangesAsync();

            return(good.Id);
        }