コード例 #1
0
 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());
 }
コード例 #2
0
 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()));
 }