правки :)
This commit is contained in:
parent
295e3ee360
commit
128580bce8
@ -8,6 +8,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ServiceStationBusinessLogic.BusinessLogics
|
||||
@ -120,16 +121,21 @@ namespace ServiceStationBusinessLogic.BusinessLogics
|
||||
throw new ArgumentNullException("Нет ФИО поручителя", nameof(model.GuarantorFIO));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.GuarantorPassword))
|
||||
if (string.IsNullOrEmpty(model.GuarantorPassword) || !Regex.IsMatch(model.GuarantorPassword, @"^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,}$", RegexOptions.IgnoreCase))
|
||||
{
|
||||
throw new ArgumentNullException("Нет пароля поручителя", nameof(model.GuarantorPassword));
|
||||
throw new ArgumentNullException("Пароль введен некорректно", nameof(model.GuarantorPassword));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.GuarantorNumber))
|
||||
if (string.IsNullOrEmpty(model.GuarantorNumber) || !Regex.IsMatch(model.GuarantorNumber, @"^((8|\+7)[\- ]?)?(\(?\d{3}\)?[\- ]?)?[\d\- ]{7,10}$", RegexOptions.IgnoreCase))
|
||||
{
|
||||
throw new ArgumentNullException("Нет номера телефона поручителя", nameof(model.GuarantorNumber));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.GuarantorEmail) || !Regex.IsMatch(model.GuarantorEmail, @"([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)", RegexOptions.IgnoreCase))
|
||||
{
|
||||
throw new ArgumentNullException("Почта введена некорректно", nameof(model.GuarantorEmail));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Guarantor. GuarantorFIO:{GuarantorFIO}.GuarantorPassword:{GuarantorPassword}.GuarantorNumber:{GuarantorNumber} Id: {Id}", model.GuarantorFIO, model.GuarantorPassword, model.GuarantorNumber, model.Id);
|
||||
|
||||
var element = _guarantorStorage.GetElement(new GuarantorSearchModel
|
||||
@ -137,10 +143,14 @@ namespace ServiceStationBusinessLogic.BusinessLogics
|
||||
GuarantorNumber = model.GuarantorNumber
|
||||
});
|
||||
|
||||
if (element != null && element.Id != model.Id)
|
||||
if (element != null)
|
||||
{
|
||||
throw new InvalidOperationException("Поручитель с таким номером уже есть");
|
||||
}
|
||||
if (model.GuarantorNumber[0] == '+')
|
||||
{
|
||||
model.GuarantorNumber.TrimStart('+');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,6 +51,15 @@ namespace ServiceStationDatabaseImplement.Implements
|
||||
.FirstOrDefault(x => x.GuarantorNumber.Contains(model.GuarantorNumber) && x.GuarantorPassword.Contains(model.GuarantorPassword))?
|
||||
.GetViewModel;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(model.GuarantorNumber))
|
||||
{
|
||||
return context.Guarantors
|
||||
.Include(x => x.SpareParts)
|
||||
.Include(x => x.Repairs)
|
||||
.Include(x => x.Works)
|
||||
.FirstOrDefault(x => x.GuarantorNumber.Contains(model.GuarantorNumber))?
|
||||
.GetViewModel;
|
||||
}
|
||||
return context.Guarantors
|
||||
.Include(x => x.SpareParts)
|
||||
.Include(x => x.Repairs)
|
||||
|
@ -222,17 +222,17 @@ namespace ServiceStationDatabaseImplement.Migrations
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_SparePartRepairs", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_SparePartRepairs_Repairs_RepairId",
|
||||
column: x => x.RepairId,
|
||||
principalTable: "Repairs",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_SparePartRepairs_SpareParts_SparePartId",
|
||||
column: x => x.SparePartId,
|
||||
principalTable: "SpareParts",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_SparePartRepairs_Repairs_RepairId",
|
||||
column: x => x.RepairId,
|
||||
principalTable: "Repairs",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
@ -328,16 +328,16 @@ namespace ServiceStationDatabaseImplement.Migrations
|
||||
table: "Repairs",
|
||||
column: "GuarantorId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_SparePartRepairs_RepairId",
|
||||
table: "SparePartRepairs",
|
||||
column: "RepairId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_SparePartRepairs_SparePartId",
|
||||
table: "SparePartRepairs",
|
||||
column: "SparePartId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_SparePartRepairs_RepairId",
|
||||
table: "SparePartRepairs",
|
||||
column: "RepairId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_SpareParts_GuarantorId",
|
||||
table: "SpareParts",
|
||||
|
@ -241,18 +241,18 @@ namespace ServiceStationDatabaseImplement.Migrations
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("RepairId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("SparePartId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("RepairId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RepairId");
|
||||
|
||||
b.HasIndex("SparePartId");
|
||||
|
||||
b.HasIndex("RepairId");
|
||||
|
||||
b.ToTable("SparePartRepairs");
|
||||
});
|
||||
|
||||
@ -430,21 +430,22 @@ namespace ServiceStationDatabaseImplement.Migrations
|
||||
|
||||
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.SparePartRepair", b =>
|
||||
{
|
||||
b.HasOne("ServiceStationDatabaseImplement.Models.Repair", "Repair")
|
||||
.WithMany("SpareParts")
|
||||
.HasForeignKey("RepairId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ServiceStationDatabaseImplement.Models.SparePart", "SparePart")
|
||||
.WithMany("SparePartRepairs")
|
||||
.HasForeignKey("SparePartId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Repair");
|
||||
b.HasOne("ServiceStationDatabaseImplement.Models.Repair", "Repair")
|
||||
.WithMany("SpareParts")
|
||||
.HasForeignKey("RepairId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("SparePart");
|
||||
|
||||
b.Navigation("Repair");
|
||||
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.SparePartWork", b =>
|
||||
|
@ -39,7 +39,7 @@ namespace ServiceStationRestApi.Controllers
|
||||
{
|
||||
return _glogic.ReadElement(new GuarantorSearchModel
|
||||
{
|
||||
GuarantorNumber = guarantorNumber,
|
||||
GuarantorNumber = guarantorNumber.TrimStart(' '),
|
||||
GuarantorPassword = password
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user