diff --git a/AsbCloudApp/Data/WellOperationDto.cs b/AsbCloudApp/Data/WellOperationDto.cs index 310b25d5..31b50243 100644 --- a/AsbCloudApp/Data/WellOperationDto.cs +++ b/AsbCloudApp/Data/WellOperationDto.cs @@ -8,10 +8,7 @@ namespace AsbCloudApp.Data /// Операции на скважине (заведенные пользователем) /// public class WellOperationDto : ItemInfoDto, IId, IWellRelated - { - - - + { /// public int Id { get; set; } @@ -34,6 +31,7 @@ namespace AsbCloudApp.Data /// id категории операции /// [Required] + [Range(5000, int.MaxValue)] public int IdCategory { get; set; } /// diff --git a/AsbCloudInfrastructure/Services/WellOperationService/WellOperationImportService.cs b/AsbCloudInfrastructure/Services/WellOperationService/WellOperationImportService.cs index 152f329c..949aaf71 100644 --- a/AsbCloudInfrastructure/Services/WellOperationService/WellOperationImportService.cs +++ b/AsbCloudInfrastructure/Services/WellOperationService/WellOperationImportService.cs @@ -45,6 +45,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService if (categories is null) { categories = db.WellOperationCategories + .Where(c => c.Id >= 5000) .AsNoTracking() .ToList(); } @@ -299,7 +300,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService { var category = Categories.Find(c => c.Name.ToLower() == categoryName.ToLower()); if (category is null) - throw new FileFormatException($"Лист {row.Worksheet.Name}. Строка {row.RowNumber()} указана некорректная операция"); + throw new FileFormatException($"Лист {row.Worksheet.Name}. Строка {row.RowNumber()} указана некорректная операция ({categoryName})"); operation.IdCategory = category.Id; operation.CategoryName = category.Name; diff --git a/AsbCloudWebApi/Controllers/WellOperationController.cs b/AsbCloudWebApi/Controllers/WellOperationController.cs index 9d8f8a2a..864a8cca 100644 --- a/AsbCloudWebApi/Controllers/WellOperationController.cs +++ b/AsbCloudWebApi/Controllers/WellOperationController.cs @@ -1,4 +1,5 @@ using AsbCloudApp.Data; +using AsbCloudApp.Exceptions; using AsbCloudApp.Repositories; using AsbCloudApp.Requests; using AsbCloudApp.Services; @@ -9,6 +10,7 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.IO; +using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -202,7 +204,7 @@ namespace AsbCloudWebApi.Controllers [Permission] [ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)] public async Task InsertRangeAsync( - [Range(1, int.MaxValue, ErrorMessage = "Id скважины не может быть меньше 1")] int idWell, + [Range(1, int.MaxValue, ErrorMessage = "Id скважины не может быть меньше 1")] int idWell, [FromBody] IEnumerable values, CancellationToken token) { @@ -213,7 +215,7 @@ namespace AsbCloudWebApi.Controllers { value.IdWell = idWell; value.LastUpdateDate = DateTimeOffset.UtcNow; - value.IdUser = User.GetUserId(); + value.IdUser = User.GetUserId(); } var result = await operationRepository.InsertRangeAsync(values, token)