Exemplo n.º 1
0
        public async Task <IActionResult> AddElement([FromBody] ElementDetail elementDetail)
        {
            // 验证唯一识别
            var eles = _elementService.HaveSameIdentification(elementDetail.Identification);

            if (eles.Count() > 0)
            {
                ModelState.AddModelError("Identification",
                                         string.Format(ErrorMessages.WebAdmin_Element_E004, string.Join(',', eles)));
                return(BadRequest(ModelState));
            }

            await _elementService.CreateElementAsync(elementDetail);

            return(Ok());
        }