Esempio n. 1
0
 public async Task <IActionResult> UpdateElement([FromRoute] Element element)
 {
     try
     {
         return(Ok(await elementService.UpdateElementAsync(element)));
     }
     catch (ArgumentException e)
     {
         return(BadRequest(new { error = e.Message }));
     }
 }
Esempio n. 2
0
        public async Task <IActionResult> UpdateElement([FromBody] ElementDetail elementDetail)
        {
            // 验证唯一识别
            var eles = _elementService.HaveSameIdentification(Guid.Parse(elementDetail.Id), elementDetail.Identification);

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

            await _elementService.UpdateElementAsync(elementDetail);

            return(Ok());
        }