예제 #1
0
        public async Task <IActionResult> AddFactory([FromBody] string factoryName)
        {
            var saveResult = await _factoryService.AddFactory(factoryName);

            if (saveResult)
            {
                await _hubContext.Clients.All.SendAsync("ListChanged", factoryName);
            }

            return(StatusCode(200, saveResult));
        }
        /* [Route("Factory")]*/
        public async Task <IActionResult> AddFactory([FromBody] FactoryDTO model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest("Invalid model"));
                }
                await _service.AddFactory(model);

                return(StatusCode(201));
            }
            catch
            {
                return(StatusCode(400));
            }
        }