Merge pull request 'Добавить валидацию id категории операции >= 5000.' (#58) from feature/deny-category-choose into dev

Reviewed-on: http://test.digitaldrilling.ru:8080/DDrilling/AsbCloudServer/pulls/58
This commit is contained in:
Никита Фролов 2023-06-06 15:53:33 +05:00
commit b05fa001c3
3 changed files with 8 additions and 7 deletions

View File

@ -9,9 +9,6 @@ namespace AsbCloudApp.Data
/// </summary>
public class WellOperationDto : ItemInfoDto, IId, IWellRelated
{
/// <inheritdoc/>
public int Id { get; set; }
@ -34,6 +31,7 @@ namespace AsbCloudApp.Data
/// id категории операции
/// </summary>
[Required]
[Range(5000, int.MaxValue)]
public int IdCategory { get; set; }
/// <summary>

View File

@ -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;

View File

@ -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;