public async Task <IActionResult> Create([Bind("Id,Name")] Warehouse warehouse)
        {
            if (ModelState.IsValid)
            {
                await _warehouseService.AddAsync(warehouse);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(warehouse));
        }
Beispiel #2
0
        public async Task <IActionResult> AddAsync(Warehouse warehouse)
        {
            var result = await _warehouseService.AddAsync(warehouse);

            if (result.Success)
            {
                return(Ok(JsonConvert.SerializeObject(result.Message)));
            }
            return(BadRequest(JsonConvert.SerializeObject(result.Message)));
        }
Beispiel #3
0
        public async Task <IActionResult> PostWarehouse([FromBody] Warehouse warehouse)
        {
            if (!ModelState.IsValid)
            {
                _logger.LogWarning($"PostWarehouse({warehouse.Id}) invalid ModelState: {ModelState.ErrorsToString()}");
                return(BadRequest(ModelState));
            }

            await _warhouseService.AddAsync(warehouse);

            return(CreatedAtAction("GetWarehouse", new { id = warehouse.Id }, warehouse));
        }
        public async Task <ActionResult> Create(Warehouse warehouse)
        {
            try
            {
                warehouse.CreatedBy = (await GetCurrentUserAsync()).Id;

                await WarehouseService.AddAsync(warehouse);

                return(RedirectToAction(nameof(Index), new { msg = "New warehouse added successfully" }));
            }
            catch
            {
                return(View(warehouse));
            }
        }