Ejemplo n.º 1
0
        public IActionResult Post([FromBody] FlowCreation flow)
        {
            if (flow == null)
            {
                return(BadRequest());
            }

            if (flow.Name == "产品")
            {
                ModelState.AddModelError("Name", "产品名称不能有“产品”两个字");
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var flownew = Mapper.Map <Entities.Flow>(flow);

            _flowRepository.AddFlow(flownew);
            if (!_flowRepository.save())
            {
                return(StatusCode(500, "保存产品的时候出错"));
            }
            var dto = Mapper.Map <Flow>(flownew);

            return(CreatedAtRoute("GetProduct", new { id = dto.Id }, dto));
        }