forked from ddrilling/AsbCloudServer
replace ArgumentInvalidException by ValidationBadRequest in Controllers
This commit is contained in:
parent
4a6bc2c747
commit
33c49e8a48
@ -169,8 +169,9 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
if (!await UserHasAccesToWellAsync(idWell, token))
|
if (!await UserHasAccesToWellAsync(idWell, token))
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
var well = await wellService.GetOrDefaultAsync(idWell, token)
|
var well = await wellService.GetOrDefaultAsync(idWell, token);
|
||||||
?? throw new ArgumentInvalidException($"Скважина c id:{idWell} не найдена", nameof(idWell));
|
if (well is null)
|
||||||
|
return this.ValidationBadRequest(nameof(idWell), $"Скважина c id:{idWell} не найдена");
|
||||||
|
|
||||||
var stream = await dailyReportService.MakeReportAsync(idWell, date, token);
|
var stream = await dailyReportService.MakeReportAsync(idWell, date, token);
|
||||||
if (stream is null)
|
if (stream is null)
|
||||||
|
@ -119,10 +119,10 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
if (files.Count > 1)
|
if (files.Count > 1)
|
||||||
throw new ArgumentInvalidException("only 1 file can be uploaded", nameof(files));
|
return this.ValidationBadRequest(nameof(files), "only 1 file can be uploaded");
|
||||||
|
|
||||||
if (files.Count == 0)
|
if (files.Count == 0)
|
||||||
throw new ArgumentInvalidException("at list 1 file should be uploaded", nameof(files));
|
return this.ValidationBadRequest(nameof(files), "at list 1 file should be uploaded");
|
||||||
|
|
||||||
var fileName = files[0].FileName;
|
var fileName = files[0].FileName;
|
||||||
|
|
||||||
|
@ -87,8 +87,9 @@ public class NotificationController : ControllerBase
|
|||||||
public async Task<IActionResult> GetAsync([Required] int idNotification,
|
public async Task<IActionResult> GetAsync([Required] int idNotification,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var notification = await notificationRepository.GetOrDefaultAsync(idNotification, cancellationToken)
|
var notification = await notificationRepository.GetOrDefaultAsync(idNotification, cancellationToken);
|
||||||
?? throw new ArgumentInvalidException("Уведомление не найдено", nameof(idNotification));
|
if (notification is null)
|
||||||
|
return this.ValidationBadRequest(nameof(idNotification), "Уведомление не найдено");
|
||||||
|
|
||||||
return Ok(notification);
|
return Ok(notification);
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,8 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
|
|
||||||
var result = await service.UpsertAsync((int)userId, key, value, token).ConfigureAwait(false);
|
var result = await service.UpsertAsync((int)userId, key, value, token).ConfigureAwait(false);
|
||||||
if (result < 0)
|
if (result < 0)
|
||||||
throw new ArgumentInvalidException("not found", nameof(key));
|
return this.ValidationBadRequest(nameof(key), "not found");
|
||||||
|
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,7 +85,8 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
|
|
||||||
var result = await service.DeleteAsync((int)userId, key, token).ConfigureAwait(false);
|
var result = await service.DeleteAsync((int)userId, key, token).ConfigureAwait(false);
|
||||||
if (result < 0)
|
if (result < 0)
|
||||||
throw new ArgumentInvalidException("not found", nameof(key));
|
return this.ValidationBadRequest(nameof(key), "not found");
|
||||||
|
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user