diff --git a/AsbCloudApp/Data/User/ContactDto.cs b/AsbCloudApp/Data/User/ContactDto.cs
index adf4793a..904d4ca2 100644
--- a/AsbCloudApp/Data/User/ContactDto.cs
+++ b/AsbCloudApp/Data/User/ContactDto.cs
@@ -1,61 +1,60 @@
using System;
using System.ComponentModel.DataAnnotations;
-namespace AsbCloudApp.Data.User
+namespace AsbCloudApp.Data.User;
+
+///
+/// Контакт
+///
+public class ContactDto : IId
{
+ ///
+ public int Id { get; set; }
+
///
- /// Контакт
+ /// ключ типа компании
///
+ [Required]
+ [Range(1, int.MaxValue)]
+ public int IdCompanyType { get; set; }
- public class ContactDto : IId
- {
- ///
- public int Id { get; set; }
+ ///
+ /// ключ скважины
+ ///
+ [Required]
+ [Range(1,int.MaxValue)]
+ public int IdWell { get; set; }
- ///
- /// ключ типа компании
- ///
- [Required]
- public int IdCompanyType { get; set; }
+ ///
+ /// ФИО
+ ///
+ [Required]
+ [StringLength(260, MinimumLength = 0, ErrorMessage = "Допустимая длина ФИО от 1 до 260 символов")]
+ public string FullName { get; set; } = null!;
- ///
- /// ключ скважины
- ///
- [Required]
- public int IdWell { get; set; }
+ ///
+ /// Email
+ ///
+ [RegularExpression(@"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$", ErrorMessage = "Некорректный email")]
+ public string? Email { get; set; }
- ///
- /// ФИО
- ///
- [Required]
- [StringLength(260, MinimumLength = 0, ErrorMessage = "Допустимая длина ФИО от 1 до 260 символов")]
- public string FullName { get; set; } = null!;
+ ///
+ /// Phone
+ ///
+ [RegularExpression(@"^(?:\+7|8)\s?(?:\(\d{3}\)|\d{3})\s?\d{3}-?\d{2}-?\d{2}$", ErrorMessage = "Некорректный номер телефона")]
+ public string? Phone { get; set; }
- ///
- /// Email
- ///
- [RegularExpression(@"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$", ErrorMessage = "Некорректный email")]
- public string? Email { get; set; }
+ ///
+ /// Должность
+ ///
+ [Required]
+ [StringLength(260, MinimumLength = 1, ErrorMessage = "Допустимая длина должности от 1 до 260 символов")]
+ public string Position { get; set; } = null!;
- ///
- /// Phone
- ///
- [RegularExpression(@"^(?:\+7|8)\s?(?:\(\d{3}\)|\d{3})\s?\d{3}-?\d{2}-?\d{2}$", ErrorMessage = "Некорректный номер телефона")]
- public string? Phone { get; set; }
-
- ///
- /// Должность
- ///
- [Required]
- [StringLength(260, MinimumLength = 1, ErrorMessage = "Допустимая длина должности от 1 до 260 символов")]
- public string Position { get; set; } = null!;
-
- ///
- /// Компания
- ///
- [Required]
- [StringLength(260, MinimumLength = 3, ErrorMessage = "Допустимая длина должности от 3 до 260 символов")]
- public string Company { get; set; } = null!;
-
- }
+ ///
+ /// Компания
+ ///
+ [Required]
+ [StringLength(260, MinimumLength = 3, ErrorMessage = "Допустимая длина названия компании от 3 до 260 символов")]
+ public string Company { get; set; } = null!;
}
diff --git a/AsbCloudWebApi/Controllers/WellOperationController.cs b/AsbCloudWebApi/Controllers/WellOperationController.cs
index cab7e32c..d4723657 100644
--- a/AsbCloudWebApi/Controllers/WellOperationController.cs
+++ b/AsbCloudWebApi/Controllers/WellOperationController.cs
@@ -17,6 +17,7 @@ using AsbCloudApp.Services.WellOperationImport;
using AsbCloudApp.Data.WellOperationImport.Options;
using AsbCloudApp.Exceptions;
using AsbCloudDb.Model;
+using AsbCloudInfrastructure;
namespace AsbCloudWebApi.Controllers
{
@@ -267,7 +268,7 @@ namespace AsbCloudWebApi.Controllers
if (!await CanUserEditWellOperationsAsync(idWell, cancellationToken))
return Forbid();
- if (deleteBeforeInsert && wellOperations.Any())
+ if (deleteBeforeInsert)
{
var existingOperations = await operationRepository.GetAsync(new WellOperationRequest
{
@@ -356,7 +357,6 @@ namespace AsbCloudWebApi.Controllers
[HttpPost("import/fact/default/{deleteBeforeInsert:bool}")]
[ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
- [ProducesResponseType(StatusCodes.Status204NoContent)]
[Permission]
public Task ImportFactDefaultExcelFileAsync(int idWell,
[FromForm] IFormFileCollection files,
@@ -384,7 +384,6 @@ namespace AsbCloudWebApi.Controllers
[HttpPost("import/plan/default")]
[ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
- [ProducesResponseType(StatusCodes.Status204NoContent)]
[Permission]
public Task ImportPlanDefaultExcelFileAsync(int idWell,
[FromForm] IFormFileCollection files,
@@ -411,7 +410,6 @@ namespace AsbCloudWebApi.Controllers
[HttpPost("import/plan/gazpromKhantos")]
[ProducesResponseType(typeof(IEnumerable), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
- [ProducesResponseType(StatusCodes.Status204NoContent)]
[Permission]
public Task ImportPlanGazpromKhantosExcelFileAsync(int idWell,
[FromForm] IFormFileCollection files,
@@ -533,14 +531,14 @@ namespace AsbCloudWebApi.Controllers
var wellOperations = wellOperationImportService.Import(idWell, idUser.Value, options.IdType, sheet)
.OrderBy(w => w.DateStart);
- var dateStart = wellOperations.Min(w => w.DateStart);
+ var dateStart = wellOperations.MinOrDefault(w => w.DateStart);
foreach (var wellOperation in wellOperations)
- wellOperation.Day = (wellOperation.DateStart - dateStart).TotalDays;
-
- if (!wellOperations.Any())
- return NoContent();
-
+ {
+ if (dateStart.HasValue)
+ wellOperation.Day = (wellOperation.DateStart - dateStart.Value).TotalDays;
+ }
+
//TODO: очень быстрый костыль
if (deleteBeforeInsert is not null && options.IdType == WellOperation.IdOperationTypeFact)
{