public IActionResult Update( [SwaggerParameter("Clock name", Required = true)] string?clock, [FromQuery, SwaggerParameter("API-key", Required = true)] string?apiKey, [FromQuery, SwaggerParameter("User Name", Required = true)] string?user, [FromBody, SwaggerRequestBody("Clock settings", Required = true)] ClockSettings settings) { if (settings is null || string.IsNullOrWhiteSpace(clock)) { return(BadRequest()); } if (Servers.Exists(clock) && !IsAdministrator(apiKey, clock, settings.Password)) { return(Unauthorized()); } Servers.Instance(clock).Update(settings.AsSettings(), RemoteIpAddress, user); return(Ok()); }
public IActionResult Update( [SwaggerParameter("Clock name", Required = true)] string?clock, [FromQuery, SwaggerParameter("Username", Required = true)] string?user, [FromQuery, SwaggerParameter("Administrator password", Required = true)] string?password, [FromBody, SwaggerRequestBody("Clock settings", Required = true)] ClockSettings settings) { if (settings is null || string.IsNullOrWhiteSpace(clock)) { return(BadRequest(SettingsErrorMessage(clock))); } if (Servers.Exists(clock) && !IsAdministrator(clock, password)) { return(Unauthorized(AdministratorUnauthorizedErrorMessage())); } if (Servers.Instance(clock).Update(user, password, settings.AsSettings(), RemoteIpAddress)) { return(Ok()); } return(Unauthorized(UserUnauthorizedErrorMessage())); }