public async Task <ActionResult> Put([FromBody] CircleUpdateDto model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var circleFromRepo = await this._repo.GetCircle((int)model.Id); if (circleFromRepo == null) { return(NotFound()); } if (!await _repo.CheckUpdatePermission(model.AppUserId, (int)model.Id)) { return(Unauthorized()); } if (!model.ApprovalRequired && circleFromRepo.ApprovalRequired) { await _repo.ApproveAll(circleFromRepo.Id); } _mapper.Map(model, circleFromRepo); try { await _repo.SaveAll(); } catch (System.Exception ex) { this._logger.LogError("Failed to update circle: " + ex.Message); return(BadRequest("Failed to update circle: " + ex.Message)); } return(Ok()); }