Exemplo n.º 1
0
 public async Task <IActionResult> PostZonePolygon([FromRoute] Zone zone, [FromBody] Polygon element)
 {
     try
     {
         return(Ok(await elementService.CreateElementAsync(zone, element)));
     }
     catch (ArgumentException e)
     {
         return(BadRequest(new { error = e.Message }));
     }
 }
Exemplo n.º 2
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());
        }