public IHttpActionResult Update(Inspector inspector) { if (UserAccess.GetUserAccess(User.Identity.Name).current_access == UserAccess.access_type.admin_access) { return(Ok(inspector.Update())); } else { return(Ok()); } }
void IBinding.Update() { if (!HasInspector || !m_Root.IsPathValid(m_BasePath)) { return; } try { Inspector.Update(); } catch (Exception exception) { Debug.LogException(exception); } }
public async Task <IActionResult> Update(Guid id, [FromBody] InspectorDTO entity) { try { if (entity == null) { _logger.LogError("Inspector object sent from client is null."); return(BadRequest("Inspector object is null")); } if (!ModelState.IsValid) { _logger.LogError("Invalid inspector object sent from client."); return(BadRequest("Invalid model object")); } Inspector inspector = _mapper.Map <InspectorDTO, Inspector>(entity); Inspector foundInspector = await _unitOfWork.Inspector.FindAsync(inspector.Id); if (foundInspector == null) { _logger.LogError($"Inspector with id: {id}, hasn't been found in db."); return(NotFound()); } foundInspector.Update(inspector); await _unitOfWork.CompleteAsync(); return(NoContent()); } catch (Exception ex) { _logger.LogError($"Something went wrong inside Update action: {ex.Message}"); return(StatusCode(500, "Internal server error")); } }