public async Task <IActionResult> UpdateElement([FromRoute] Element element) { try { return(Ok(await elementService.UpdateElementAsync(element))); } catch (ArgumentException e) { return(BadRequest(new { error = e.Message })); } }
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()); }