Release 1.0.8-rc10
This commit is contained in:
parent
d5b2930092
commit
8b9a9103fc
9 changed files with 302 additions and 19 deletions
|
|
@ -109,6 +109,21 @@ namespace Yavsc.Models
|
|||
|
||||
builder.Entity<Activity>().Property(a => a.ParentCode).IsRequired(false);
|
||||
|
||||
builder.Entity<Country>().HasKey(c => c.Code);
|
||||
builder.Entity<PerformerCodeInputValidation>()
|
||||
.HasOne(v => v.Country)
|
||||
.WithMany()
|
||||
.HasForeignKey(v => v.CountryCode)
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
builder.Entity<Country>().HasData(
|
||||
PerformerCodeInputValidationCatalog.Countries
|
||||
);
|
||||
|
||||
builder.Entity<PerformerCodeInputValidation>().HasData(
|
||||
PerformerCodeInputValidationCatalog.Rules
|
||||
);
|
||||
|
||||
builder.Entity<Client>().Property("Id").UseIdentityAlwaysColumn();
|
||||
builder.Entity<ClientSecret>().Property("Id").UseIdentityAlwaysColumn();
|
||||
builder.Entity<ClientScope>().Property("Id").UseIdentityAlwaysColumn();
|
||||
|
|
@ -262,6 +277,8 @@ namespace Yavsc.Models
|
|||
|
||||
public DbSet<HairMultiCutQuery> HairMultiCutQueries { get; set; }
|
||||
public DbSet<PerformerProfile> Performers { get; set; }
|
||||
public DbSet<Country> Countries { get; set; }
|
||||
public DbSet<PerformerCodeInputValidation> PerformerCodeInputValidations { get; set; }
|
||||
|
||||
public DbSet<Estimate> Estimates { get; set; }
|
||||
public DbSet<Signature> Signatures { get; set; }
|
||||
|
|
|
|||
|
|
@ -4,12 +4,14 @@ using System.ComponentModel.DataAnnotations.Schema;
|
|||
namespace Yavsc.Models.Workflow
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using Models.Relationship;
|
||||
using Newtonsoft.Json;
|
||||
using Yavsc.Attributes.Validation;
|
||||
using Yavsc.Workflow;
|
||||
|
||||
public class PerformerProfile : IPerformerProfile {
|
||||
public class PerformerProfile : IPerformerProfile, IValidatableObject {
|
||||
|
||||
[Key]
|
||||
public string PerformerId { get; set; }
|
||||
|
|
@ -20,8 +22,11 @@ namespace Yavsc.Models.Workflow
|
|||
[Display(Name="Activity"), JsonIgnore]
|
||||
public virtual List<UserActivity> Activity { get; set; }
|
||||
|
||||
[Required,YaStringLength(14),Display(Name="SIREN"),
|
||||
RegularExpression(@"^[0-9]{9,14}$", ErrorMessage = "Only numbers are allowed here")]
|
||||
[Required, Display(Name = "Country of exercise")]
|
||||
[MinLength(2), MaxLength(2)]
|
||||
public string ExerciseCountryCode { get; set; } = "fr";
|
||||
|
||||
[Required,YaStringLength(14),Display(Name="SIREN")]
|
||||
public string SIREN { get; set; }
|
||||
|
||||
public long OrganizationAddressId { get; set; }
|
||||
|
|
@ -60,5 +65,40 @@ namespace Yavsc.Models.Workflow
|
|||
return Performer?.Posts?.Count > 0 ;
|
||||
} }
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
var countryCode = PerformerCodeInputValidationCatalog.NormalizeCountryCode(ExerciseCountryCode);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(countryCode))
|
||||
{
|
||||
yield return new ValidationResult(
|
||||
"Le pays d'exercice est requis.",
|
||||
new[] { nameof(ExerciseCountryCode) });
|
||||
yield break;
|
||||
}
|
||||
|
||||
var rule = PerformerCodeInputValidationCatalog.GetRule(countryCode);
|
||||
if (rule is null)
|
||||
{
|
||||
yield return new ValidationResult(
|
||||
"Le pays d'exercice doit etre l'un des suivants: fr, en, pt.",
|
||||
new[] { nameof(ExerciseCountryCode) });
|
||||
yield break;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(SIREN))
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
var normalizedCode = SIREN.Trim();
|
||||
if (!Regex.IsMatch(normalizedCode, rule.RegularExpression, RegexOptions.CultureInvariant))
|
||||
{
|
||||
yield return new ValidationResult(
|
||||
rule.ErrorMessage,
|
||||
new[] { nameof(SIREN) });
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue