Example #1
0
        public override async Task <Result> Handler(CreateWarehouse message)
        {
            var warehouse = new Warehouse(message.FirstName, message.LastName, message.Email, message.IsActive);
            await _warehouseRepository.AddAsync(warehouse);

            await _warehouseRepository.SaveEntitiesAsync();

            return(new Result());
        }
Example #2
0
        public async Task <IActionResult> Post(WarehouseIndexViewModel model)
        {
            var warehouse = new Warehouse
            {
                Id      = model.Id,
                Name    = model.Name,
                Address = model.Address,
                Vendor  = model.Vendor
            };
            await _warehouseRepository.AddAsync(warehouse);

            TempData["SM"] = "Вы успешно создали.";
            return(RedirectToAction("Index", "Warehouse"));
        }
Example #3
0
        public async Task <Result> Handle(MaterialImportCommand request, CancellationToken token)
        {
            foreach (var requestWarehouse in request.Warehouses)
            {
                var warehouse = _repository.Warehouses.FirstOrDefault(w => w.Name == requestWarehouse.Name);

                if (warehouse == null)
                {
                    warehouse = new Warehouse(requestWarehouse.Name);

                    await _repository.AddAsync(warehouse);
                }

                warehouse.AddMaterial(request.Name, request.Id, requestWarehouse.Count);
            }

            return(Result.Ok());
        }