diff --git a/Models/Agent.cs b/Models/Agent.cs new file mode 100644 index 0000000..cda973c --- /dev/null +++ b/Models/Agent.cs @@ -0,0 +1,27 @@ +using System.ComponentModel.DataAnnotations; + + +namespace PoliceOp.Models +{ + public class Agent : Personne + { + + /// + /// Propriétés relatives à l'agent + /// + + [Required] + public string Matricule { get; set; } + + [Required] + public string Grade { get; set; } + + [Required] + public string Corps { get; set; } + + [Required] + public string PasswordHash { get; set; } + + + } +} diff --git a/Models/Audiences.cs b/Models/Audiences.cs new file mode 100644 index 0000000..4d41ab8 --- /dev/null +++ b/Models/Audiences.cs @@ -0,0 +1,9 @@ +namespace PoliceOp.Models +{ + public enum Audiences + { + TerminalMobile, + TerminalDesktop, + PoliceOpAPI + } +} diff --git a/Models/AvisRecherche.cs b/Models/AvisRecherche.cs new file mode 100644 index 0000000..6853863 --- /dev/null +++ b/Models/AvisRecherche.cs @@ -0,0 +1,21 @@ +using System; +using System.ComponentModel.DataAnnotations; + +namespace PoliceOp.Models +{ + public class AvisRecherche + { + [Key] + public Guid UID { get; set; } + + [Required] + public DateTime DateEmission { get; set; } + + [Required] + public string StatutRecherche { get; set; } + + public string Informations { get; set; } + + public virtual Personne PersonneRecherchee { get; set; } + } +} diff --git a/Models/Biometrie.cs b/Models/Biometrie.cs new file mode 100644 index 0000000..9bb3109 --- /dev/null +++ b/Models/Biometrie.cs @@ -0,0 +1,22 @@ +using System; +using System.ComponentModel.DataAnnotations; + + +namespace PoliceOp.Models +{ + public class Biometrie + { + [Key] + public Guid UID { get; set; } + + public virtual byte[] DonneesFaciales { get; set; } + + public virtual byte[] DonneesDigitales { get; set; } + + public bool Comparer() + { + return true; + } + + } +} diff --git a/Models/CaptPhoto.cs b/Models/CaptPhoto.cs new file mode 100644 index 0000000..9805c71 --- /dev/null +++ b/Models/CaptPhoto.cs @@ -0,0 +1,7 @@ +namespace PoliceOp.Models +{ + public enum CaptPhoto + { + EliteCap1, EliteCap2, EliteCap3, EliteCap4 + } +} diff --git a/Models/Diffusion.cs b/Models/Diffusion.cs new file mode 100644 index 0000000..a7c9ca3 --- /dev/null +++ b/Models/Diffusion.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace PoliceOp.Models +{ + public class Diffusion + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int DiffusionId { get; set; } + + [ForeignKey("PersonneId")] + public int AuthorId { get; set; } + + public string Sujet { get; set; } + + [Required] + public string Details { get; set; } + + public string Cible { get; set; } = "Agents"; + + public DateTime DateDiffusion { get; set; } + + public virtual ICollection PiecesJointes { get; set; } + } +} diff --git a/Models/Issuers.cs b/Models/Issuers.cs new file mode 100644 index 0000000..cfed4f8 --- /dev/null +++ b/Models/Issuers.cs @@ -0,0 +1,9 @@ +namespace PoliceOp.Models +{ + public enum Issuers + { + FastlaneApp, + OpCenterApp, + PoliceOpAPI + } +} diff --git a/Models/Operateur.cs b/Models/Operateur.cs new file mode 100644 index 0000000..a17b6df --- /dev/null +++ b/Models/Operateur.cs @@ -0,0 +1,11 @@ +using System.ComponentModel.DataAnnotations; + +namespace PoliceOp.Models +{ + public class Operateur : Agent + { + [Required] + public string Service { get; set; } + + } +} diff --git a/Models/Personne.cs b/Models/Personne.cs new file mode 100644 index 0000000..9fd585f --- /dev/null +++ b/Models/Personne.cs @@ -0,0 +1,78 @@ +using System; +using System.ComponentModel.DataAnnotations; + +namespace PoliceOp.Models +{ + public class Personne + { + [Key] + public int PersonneId { get; set; } + + [Required] + public string UID { get; set; } + + [Required] + public string NPI { get; set; } + + [Required] + public string IFU { get; set; } + + [Required] + public string Nom { get; set; } + + [Required] + public string Prenom { get; set; } + + [Required] + [DataType(DataType.Date)] + public DateTime DateNaissance { get; set; } + + [Required] + public string Telephone { get; set; } + + [Required] + public string Sexe { get; set; } + + [Required] + public string LieuNaissance { get; set; } + + [Required] + public string Nationalite { get; set; } + + [Required] + public string Profession { get; set; } + + [Required] + public string SituationMatrimoniale { get; set; } + + [Required] + public string SignesParticuliers { get; set; } + + [Required] + public string CouleurYeux { get; set; } + + [Required] + public string CouleurCheveux { get; set; } + + [Required] + public string Teint { get; set; } + + [Required] + public double Taille { get; set; } + + [Required] + public string PersonnePhoto { get; set; } + + public virtual Biometrie Biometrie { get; set; } + + [Required] + public virtual Residence Residence { get; set; } + + [Required] + public int PereId { get; set; } + + [Required] + public int MereId { get; set; } + } + +} diff --git a/Models/PhotoEnum.cs b/Models/PhotoEnum.cs new file mode 100644 index 0000000..313fa64 --- /dev/null +++ b/Models/PhotoEnum.cs @@ -0,0 +1,13 @@ +namespace PoliceOp.Models +{ + public enum PhotoEnum + { + Homme1, + Homme2, + Homme3, + Femme1, + Femme2, + Femme3 + } + +} diff --git a/Models/PieceJointe.cs b/Models/PieceJointe.cs new file mode 100644 index 0000000..349f0de --- /dev/null +++ b/Models/PieceJointe.cs @@ -0,0 +1,22 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace PoliceOp.Models +{ + public class PieceJointe + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public Guid PieceJointeId { get; set; } + + [Required] + public string NomFichier { get; set; } + + [Required] + public string ExtensionFichier { get; set; } + + [Required] + public byte[] Fichier { get; set; } + } +} diff --git a/Models/Requete.cs b/Models/Requete.cs new file mode 100644 index 0000000..02a8643 --- /dev/null +++ b/Models/Requete.cs @@ -0,0 +1,17 @@ +using System; +using System.ComponentModel.DataAnnotations; + +namespace PoliceOp.Models +{ + public class Requete + { + [Key] + public Guid UID { get; set; } + + [Required] + public string TermeRequete { get; set; } + + public DateTime DateRequete { get; set; } = DateTime.Now; + + } +} diff --git a/Models/Residence.cs b/Models/Residence.cs new file mode 100644 index 0000000..1266407 --- /dev/null +++ b/Models/Residence.cs @@ -0,0 +1,38 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + + +namespace PoliceOp.Models +{ + [ComplexType] + public class Residence + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public Guid ResidenceId { get; set; } + + [Required] + public string Type { get; set; } + + public string Rue { get; set; } + + public string NumeroParcelle { get; set; } + + public string NumeroChambre { get; set; } + + public virtual string CoordonneesGeo { get; set; } + + public string Description { get; set; } + + [ForeignKey("PersonneId")] + public virtual Personne Proprietaire { get; set; } + + [NotMapped] + public string AdresseComplete + { + get { return $"{NumeroParcelle} Rue {Rue}, C{NumeroChambre}"; } + } + + } +} diff --git a/Models/Session.cs b/Models/Session.cs new file mode 100644 index 0000000..dc67077 --- /dev/null +++ b/Models/Session.cs @@ -0,0 +1,16 @@ +using System; +using System.ComponentModel.DataAnnotations; + +namespace PoliceOp.Models +{ + public class Session + { + [Key] + public Guid SessionID { get; set; } + + public override string ToString() + { + return SessionID.ToString(); + } + } +} diff --git a/Models/SessionVM.cs b/Models/SessionVM.cs new file mode 100644 index 0000000..30f03fc --- /dev/null +++ b/Models/SessionVM.cs @@ -0,0 +1,8 @@ +namespace PoliceOp.Models +{ + public class SessionVM + { + public string SessionID { get; set; } + public int AgentID { get; set; } + } +} diff --git a/Models/Sexe.cs b/Models/Sexe.cs new file mode 100644 index 0000000..6fbdd1a --- /dev/null +++ b/Models/Sexe.cs @@ -0,0 +1,8 @@ +namespace PoliceOp.Models +{ + public enum Sexe + { + M, + F + } +} diff --git a/PoliceOp.API/Controllers/AvisRechercheController.cs b/PoliceOp.API/Controllers/AvisRechercheController.cs index b80f8e9..15ff1e5 100644 --- a/PoliceOp.API/Controllers/AvisRechercheController.cs +++ b/PoliceOp.API/Controllers/AvisRechercheController.cs @@ -59,6 +59,8 @@ public async Task> GetAvisRecherche(Guid id) return NotFound(); } + avisRecherche.PersonneRecherchee = await _context.Personnes.FindAsync(avisRecherche.PersonneRechercheeId); + return avisRecherche; } @@ -67,8 +69,6 @@ public async Task> GetAvisRecherche(Guid id) } // PUT: api/AvisRecherche/5 - // To protect from overposting attacks, enable the specific properties you want to bind to, for - // more details, see https://go.microsoft.com/fwlink/?linkid=2123754. [HttpPut("{id}")] public async Task PutAvisRecherche(Guid id, AvisRecherche avisRecherche) { @@ -106,17 +106,17 @@ public async Task PutAvisRecherche(Guid id, AvisRecherche avisRec } // POST: api/AvisRecherche - // To protect from overposting attacks, enable the specific properties you want to bind to, for - // more details, see https://go.microsoft.com/fwlink/?linkid=2123754. [HttpPost] public async Task> PostAvisRecherche(AvisRecherche avisRecherche) { if (await SessionExists(HttpContext)) { + //Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(avisRecherche.PersonneRecherchee)); + _context.AvisRecherches.Add(avisRecherche); await _context.SaveChangesAsync(); - return CreatedAtAction("GetAvisRecherche", new { id = avisRecherche.UID }, avisRecherche); + return Ok(); } return Unauthorized("Session ID is Required"); diff --git a/PoliceOp.API/Controllers/ZeroController.cs b/PoliceOp.API/Controllers/ZeroController.cs index 2dd2386..4ed18f7 100644 --- a/PoliceOp.API/Controllers/ZeroController.cs +++ b/PoliceOp.API/Controllers/ZeroController.cs @@ -31,11 +31,11 @@ public async Task GetToken() { var token = jWTService.TokenizeID("89898598", "77a8zeea87", "Session", Models.Issuers.PoliceOpAPI, Models.Audiences.TerminalDesktop); - //await GenerateData(1500, 450); + await GenerateData(1500, 450); - //await ctx.SaveChangesAsync(); + await ctx.SaveChangesAsync(); //EraseData(); - //Console.WriteLine("Done!"); + Console.WriteLine("Done!"); int totalA = ctx.Agents.Count(); int totalP = ctx.Personnes.Count(); diff --git a/PoliceOp.API/Migrations/20210621151828_MigZero.Designer.cs b/PoliceOp.API/Migrations/20210623170714_InitialMigration001.Designer.cs similarity index 95% rename from PoliceOp.API/Migrations/20210621151828_MigZero.Designer.cs rename to PoliceOp.API/Migrations/20210623170714_InitialMigration001.Designer.cs index d7c598b..a2fc61d 100644 --- a/PoliceOp.API/Migrations/20210621151828_MigZero.Designer.cs +++ b/PoliceOp.API/Migrations/20210623170714_InitialMigration001.Designer.cs @@ -10,8 +10,8 @@ namespace PoliceOp.API.Migrations { [DbContext(typeof(PoliceOpAPIContext))] - [Migration("20210621151828_MigZero")] - partial class MigZero + [Migration("20210623170714_InitialMigration001")] + partial class InitialMigration001 { protected override void BuildTargetModel(ModelBuilder modelBuilder) { @@ -33,7 +33,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("Informations") .HasColumnType("nvarchar(max)"); - b.Property("PersonneRechercheePersonneId") + b.Property("PersonneRechercheeId") .HasColumnType("int"); b.Property("StatutRecherche") @@ -42,8 +42,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasKey("UID"); - b.HasIndex("PersonneRechercheePersonneId"); - b.ToTable("AvisRecherches"); }); @@ -71,6 +69,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + b.Property("AgentPersonneId") + .HasColumnType("int"); + b.Property("AuthorId") .HasColumnType("int"); @@ -89,6 +90,8 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasKey("DiffusionId"); + b.HasIndex("AgentPersonneId"); + b.ToTable("Diffusions"); }); @@ -319,11 +322,11 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasDiscriminator().HasValue("Operateur"); }); - modelBuilder.Entity("PoliceOp.Models.AvisRecherche", b => + modelBuilder.Entity("PoliceOp.Models.Diffusion", b => { - b.HasOne("PoliceOp.Models.Personne", "PersonneRecherchee") - .WithMany() - .HasForeignKey("PersonneRechercheePersonneId"); + b.HasOne("PoliceOp.Models.Agent", null) + .WithMany("ListeDiffusions") + .HasForeignKey("AgentPersonneId"); }); modelBuilder.Entity("PoliceOp.Models.Personne", b => diff --git a/PoliceOp.API/Migrations/20210621151828_MigZero.cs b/PoliceOp.API/Migrations/20210623170714_InitialMigration001.cs similarity index 94% rename from PoliceOp.API/Migrations/20210621151828_MigZero.cs rename to PoliceOp.API/Migrations/20210623170714_InitialMigration001.cs index 9849559..7f9d40e 100644 --- a/PoliceOp.API/Migrations/20210621151828_MigZero.cs +++ b/PoliceOp.API/Migrations/20210623170714_InitialMigration001.cs @@ -1,40 +1,38 @@ -using Microsoft.EntityFrameworkCore.Migrations; -using System; +using System; +using Microsoft.EntityFrameworkCore.Migrations; namespace PoliceOp.API.Migrations { - public partial class MigZero : Migration + public partial class InitialMigration001 : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( - name: "BioData", + name: "AvisRecherches", columns: table => new { UID = table.Column(nullable: false), - DonneesFaciales = table.Column(nullable: true), - DonneesDigitales = table.Column(nullable: true) + DateEmission = table.Column(nullable: false), + StatutRecherche = table.Column(nullable: false), + Informations = table.Column(nullable: true), + PersonneRechercheeId = table.Column(nullable: false) }, constraints: table => { - table.PrimaryKey("PK_BioData", x => x.UID); + table.PrimaryKey("PK_AvisRecherches", x => x.UID); }); migrationBuilder.CreateTable( - name: "Diffusions", + name: "BioData", columns: table => new { - DiffusionId = table.Column(nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - AuthorId = table.Column(nullable: false), - Sujet = table.Column(nullable: true), - Details = table.Column(nullable: false), - Cible = table.Column(nullable: true), - DateDiffusion = table.Column(nullable: false) + UID = table.Column(nullable: false), + DonneesFaciales = table.Column(nullable: true), + DonneesDigitales = table.Column(nullable: true) }, constraints: table => { - table.PrimaryKey("PK_Diffusions", x => x.DiffusionId); + table.PrimaryKey("PK_BioData", x => x.UID); }); migrationBuilder.CreateTable( @@ -107,42 +105,24 @@ protected override void Up(MigrationBuilder migrationBuilder) }); migrationBuilder.CreateTable( - name: "PieceJointes", - columns: table => new - { - PieceJointeId = table.Column(nullable: false), - NomFichier = table.Column(nullable: false), - ExtensionFichier = table.Column(nullable: false), - Fichier = table.Column(nullable: false), - DiffusionId = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_PieceJointes", x => x.PieceJointeId); - table.ForeignKey( - name: "FK_PieceJointes_Diffusions_DiffusionId", - column: x => x.DiffusionId, - principalTable: "Diffusions", - principalColumn: "DiffusionId", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "AvisRecherches", + name: "Diffusions", columns: table => new { - UID = table.Column(nullable: false), - DateEmission = table.Column(nullable: false), - StatutRecherche = table.Column(nullable: false), - Informations = table.Column(nullable: true), - PersonneRechercheePersonneId = table.Column(nullable: true) + DiffusionId = table.Column(nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + AuthorId = table.Column(nullable: false), + Sujet = table.Column(nullable: true), + Details = table.Column(nullable: false), + Cible = table.Column(nullable: true), + DateDiffusion = table.Column(nullable: false), + AgentPersonneId = table.Column(nullable: true) }, constraints: table => { - table.PrimaryKey("PK_AvisRecherches", x => x.UID); + table.PrimaryKey("PK_Diffusions", x => x.DiffusionId); table.ForeignKey( - name: "FK_AvisRecherches_Personnes_PersonneRechercheePersonneId", - column: x => x.PersonneRechercheePersonneId, + name: "FK_Diffusions_Personnes_AgentPersonneId", + column: x => x.AgentPersonneId, principalTable: "Personnes", principalColumn: "PersonneId", onDelete: ReferentialAction.Restrict); @@ -172,10 +152,31 @@ protected override void Up(MigrationBuilder migrationBuilder) onDelete: ReferentialAction.Restrict); }); + migrationBuilder.CreateTable( + name: "PieceJointes", + columns: table => new + { + PieceJointeId = table.Column(nullable: false), + NomFichier = table.Column(nullable: false), + ExtensionFichier = table.Column(nullable: false), + Fichier = table.Column(nullable: false), + DiffusionId = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_PieceJointes", x => x.PieceJointeId); + table.ForeignKey( + name: "FK_PieceJointes_Diffusions_DiffusionId", + column: x => x.DiffusionId, + principalTable: "Diffusions", + principalColumn: "DiffusionId", + onDelete: ReferentialAction.Restrict); + }); + migrationBuilder.CreateIndex( - name: "IX_AvisRecherches_PersonneRechercheePersonneId", - table: "AvisRecherches", - column: "PersonneRechercheePersonneId"); + name: "IX_Diffusions_AgentPersonneId", + table: "Diffusions", + column: "AgentPersonneId"); migrationBuilder.CreateIndex( name: "IX_Personnes_BiometrieUID", diff --git a/PoliceOp.API/Migrations/20210623170830_InitialMigration002.Designer.cs b/PoliceOp.API/Migrations/20210623170830_InitialMigration002.Designer.cs new file mode 100644 index 0000000..3b0c14a --- /dev/null +++ b/PoliceOp.API/Migrations/20210623170830_InitialMigration002.Designer.cs @@ -0,0 +1,355 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using PoliceOp.API.Data; + +namespace PoliceOp.API.Migrations +{ + [DbContext(typeof(PoliceOpAPIContext))] + [Migration("20210623170830_InitialMigration002")] + partial class InitialMigration002 + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "3.1.15") + .HasAnnotation("Relational:MaxIdentifierLength", 128) + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + modelBuilder.Entity("PoliceOp.Models.AvisRecherche", b => + { + b.Property("UID") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("DateEmission") + .HasColumnType("datetime2"); + + b.Property("Informations") + .HasColumnType("nvarchar(max)"); + + b.Property("PersonneRechercheeId") + .HasColumnType("int"); + + b.Property("StatutRecherche") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("UID"); + + b.ToTable("AvisRecherches"); + }); + + modelBuilder.Entity("PoliceOp.Models.Biometrie", b => + { + b.Property("UID") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("DonneesDigitales") + .HasColumnType("varbinary(max)"); + + b.Property("DonneesFaciales") + .HasColumnType("varbinary(max)"); + + b.HasKey("UID"); + + b.ToTable("BioData"); + }); + + modelBuilder.Entity("PoliceOp.Models.Diffusion", b => + { + b.Property("DiffusionId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("AgentPersonneId") + .HasColumnType("int"); + + b.Property("AuthorId") + .HasColumnType("int"); + + b.Property("Cible") + .HasColumnType("nvarchar(max)"); + + b.Property("DateDiffusion") + .HasColumnType("datetime2"); + + b.Property("Details") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Sujet") + .HasColumnType("nvarchar(max)"); + + b.HasKey("DiffusionId"); + + b.HasIndex("AgentPersonneId"); + + b.ToTable("Diffusions"); + }); + + modelBuilder.Entity("PoliceOp.Models.Personne", b => + { + b.Property("PersonneId") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property("BiometrieUID") + .HasColumnType("uniqueidentifier"); + + b.Property("CouleurCheveux") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CouleurYeux") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DateNaissance") + .HasColumnType("datetime2"); + + b.Property("Discriminator") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IFU") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("LieuNaissance") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MereId") + .HasColumnType("int"); + + b.Property("NPI") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Nationalite") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Nom") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PereId") + .HasColumnType("int"); + + b.Property("PersonnePhoto") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Prenom") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Profession") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Sexe") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SignesParticuliers") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SituationMatrimoniale") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Taille") + .HasColumnType("float"); + + b.Property("Teint") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Telephone") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UID") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("PersonneId"); + + b.HasIndex("BiometrieUID"); + + b.ToTable("Personnes"); + + b.HasDiscriminator("Discriminator").HasValue("Personne"); + }); + + modelBuilder.Entity("PoliceOp.Models.PieceJointe", b => + { + b.Property("PieceJointeId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("DiffusionId") + .HasColumnType("int"); + + b.Property("ExtensionFichier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Fichier") + .IsRequired() + .HasColumnType("varbinary(max)"); + + b.Property("NomFichier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("PieceJointeId"); + + b.HasIndex("DiffusionId"); + + b.ToTable("PieceJointes"); + }); + + modelBuilder.Entity("PoliceOp.Models.Requete", b => + { + b.Property("UID") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("DateRequete") + .HasColumnType("datetime2"); + + b.Property("TermeRequete") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("UID"); + + b.ToTable("Requetes"); + }); + + modelBuilder.Entity("PoliceOp.Models.Residence", b => + { + b.Property("ResidenceId") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CoordonneesGeo") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("NumeroChambre") + .HasColumnType("nvarchar(max)"); + + b.Property("NumeroParcelle") + .HasColumnType("nvarchar(max)"); + + b.Property("PersonneId") + .HasColumnType("int"); + + b.Property("Rue") + .HasColumnType("nvarchar(max)"); + + b.Property("Type") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("ResidenceId"); + + b.HasIndex("PersonneId") + .IsUnique() + .HasFilter("[PersonneId] IS NOT NULL"); + + b.ToTable("Residences"); + }); + + modelBuilder.Entity("PoliceOp.Models.Session", b => + { + b.Property("SessionID") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.HasKey("SessionID"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("PoliceOp.Models.Agent", b => + { + b.HasBaseType("PoliceOp.Models.Personne"); + + b.Property("Corps") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Grade") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Matricule") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasDiscriminator().HasValue("Agent"); + }); + + modelBuilder.Entity("PoliceOp.Models.Operateur", b => + { + b.HasBaseType("PoliceOp.Models.Agent"); + + b.Property("Service") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasDiscriminator().HasValue("Operateur"); + }); + + modelBuilder.Entity("PoliceOp.Models.Diffusion", b => + { + b.HasOne("PoliceOp.Models.Agent", null) + .WithMany("ListeDiffusions") + .HasForeignKey("AgentPersonneId"); + }); + + modelBuilder.Entity("PoliceOp.Models.Personne", b => + { + b.HasOne("PoliceOp.Models.Biometrie", "Biometrie") + .WithMany() + .HasForeignKey("BiometrieUID"); + }); + + modelBuilder.Entity("PoliceOp.Models.PieceJointe", b => + { + b.HasOne("PoliceOp.Models.Diffusion", null) + .WithMany("PiecesJointes") + .HasForeignKey("DiffusionId"); + }); + + modelBuilder.Entity("PoliceOp.Models.Residence", b => + { + b.HasOne("PoliceOp.Models.Personne", "Proprietaire") + .WithOne("Residence") + .HasForeignKey("PoliceOp.Models.Residence", "PersonneId"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/PoliceOp.API/Migrations/20210623170830_InitialMigration002.cs b/PoliceOp.API/Migrations/20210623170830_InitialMigration002.cs new file mode 100644 index 0000000..755da74 --- /dev/null +++ b/PoliceOp.API/Migrations/20210623170830_InitialMigration002.cs @@ -0,0 +1,17 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace PoliceOp.API.Migrations +{ + public partial class InitialMigration002 : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/PoliceOp.API/Migrations/PoliceOpAPIContextModelSnapshot.cs b/PoliceOp.API/Migrations/PoliceOpAPIContextModelSnapshot.cs index b4a671a..e770f4c 100644 --- a/PoliceOp.API/Migrations/PoliceOpAPIContextModelSnapshot.cs +++ b/PoliceOp.API/Migrations/PoliceOpAPIContextModelSnapshot.cs @@ -31,7 +31,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Informations") .HasColumnType("nvarchar(max)"); - b.Property("PersonneRechercheePersonneId") + b.Property("PersonneRechercheeId") .HasColumnType("int"); b.Property("StatutRecherche") @@ -40,8 +40,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("UID"); - b.HasIndex("PersonneRechercheePersonneId"); - b.ToTable("AvisRecherches"); }); @@ -69,6 +67,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("int") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + b.Property("AgentPersonneId") + .HasColumnType("int"); + b.Property("AuthorId") .HasColumnType("int"); @@ -87,6 +88,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("DiffusionId"); + b.HasIndex("AgentPersonneId"); + b.ToTable("Diffusions"); }); @@ -317,11 +320,11 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasDiscriminator().HasValue("Operateur"); }); - modelBuilder.Entity("PoliceOp.Models.AvisRecherche", b => + modelBuilder.Entity("PoliceOp.Models.Diffusion", b => { - b.HasOne("PoliceOp.Models.Personne", "PersonneRecherchee") - .WithMany() - .HasForeignKey("PersonneRechercheePersonneId"); + b.HasOne("PoliceOp.Models.Agent", null) + .WithMany("ListeDiffusions") + .HasForeignKey("AgentPersonneId"); }); modelBuilder.Entity("PoliceOp.Models.Personne", b => diff --git a/PoliceOp.Models/Agent.cs b/PoliceOp.Models/Agent.cs index cda973c..e8118b5 100644 --- a/PoliceOp.Models/Agent.cs +++ b/PoliceOp.Models/Agent.cs @@ -1,4 +1,5 @@ using System.ComponentModel.DataAnnotations; +using System.Collections.Generic; namespace PoliceOp.Models @@ -22,6 +23,6 @@ public class Agent : Personne [Required] public string PasswordHash { get; set; } - + public virtual ICollection ListeDiffusions { get; set; } } } diff --git a/PoliceOp.Models/AvisRecherche.cs b/PoliceOp.Models/AvisRecherche.cs index 6853863..e980ccb 100644 --- a/PoliceOp.Models/AvisRecherche.cs +++ b/PoliceOp.Models/AvisRecherche.cs @@ -1,5 +1,7 @@ using System; using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.Design; namespace PoliceOp.Models { @@ -16,6 +18,12 @@ public class AvisRecherche public string Informations { get; set; } - public virtual Personne PersonneRecherchee { get; set; } + [Required] + [ForeignKey("PersonneId")] + public int PersonneRechercheeId { get; set; } + + [NotMapped] + public Personne PersonneRecherchee { get; set; } + } } diff --git a/PoliceOp.Models/Diffusion.cs b/PoliceOp.Models/Diffusion.cs index a7c9ca3..afb2ae7 100644 --- a/PoliceOp.Models/Diffusion.cs +++ b/PoliceOp.Models/Diffusion.cs @@ -21,7 +21,7 @@ public class Diffusion public string Cible { get; set; } = "Agents"; - public DateTime DateDiffusion { get; set; } + public DateTime DateDiffusion { get; set; } = DateTime.Now; public virtual ICollection PiecesJointes { get; set; } } diff --git a/PoliceOp.Models/Personne.cs b/PoliceOp.Models/Personne.cs index 9fd585f..a26d425 100644 --- a/PoliceOp.Models/Personne.cs +++ b/PoliceOp.Models/Personne.cs @@ -1,5 +1,7 @@ using System; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; namespace PoliceOp.Models { @@ -73,6 +75,7 @@ public class Personne [Required] public int MereId { get; set; } + } } diff --git a/PoliceOp.Models/Residence.cs b/PoliceOp.Models/Residence.cs index 1266407..7e89e2c 100644 --- a/PoliceOp.Models/Residence.cs +++ b/PoliceOp.Models/Residence.cs @@ -5,7 +5,6 @@ namespace PoliceOp.Models { - [ComplexType] public class Residence { [Key] diff --git a/PoliceOp.OpCenter/App.xaml b/PoliceOp.OpCenter/App.xaml index 3367402..f4f1bbf 100644 --- a/PoliceOp.OpCenter/App.xaml +++ b/PoliceOp.OpCenter/App.xaml @@ -2,7 +2,8 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:PoliceOp.OpCenter" - StartupUri="Authentication.xaml"> + xmlns:hc="https://handyorg.github.io/handycontrol" + StartupUri="Authentication.xaml"> @@ -10,7 +11,6 @@ - diff --git a/PoliceOp.OpCenter/Dialogs/NewWantedNoticeDialog.xaml b/PoliceOp.OpCenter/Dialogs/NewWantedNoticeDialog.xaml new file mode 100644 index 0000000..50a0b6b --- /dev/null +++ b/PoliceOp.OpCenter/Dialogs/NewWantedNoticeDialog.xaml @@ -0,0 +1,100 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Actif + Annulé + Résolu + + + + + + + + diff --git a/PoliceOp.OpCenter/Dialogs/NewWantedNoticeDialog.xaml.cs b/PoliceOp.OpCenter/Dialogs/NewWantedNoticeDialog.xaml.cs new file mode 100644 index 0000000..aa619c3 --- /dev/null +++ b/PoliceOp.OpCenter/Dialogs/NewWantedNoticeDialog.xaml.cs @@ -0,0 +1,119 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using RestSharp; +using RestSharp.Authenticators; + +namespace PoliceOp.OpCenter.Dialogs +{ + /// + /// Interaction logic for NewWantedNoticeDialog.xaml + /// + public partial class NewWantedNoticeDialog : HandyControl.Controls.PopupWindow + { + public List PList { get; set; } + public string keyword { get; set; } + public NewWantedNoticeDialog() + { + PList = new List(); + + InitializeComponent(); + } + + private async void DetailsBtn_Click(object sender, RoutedEventArgs e) + { + + } + + private async void SendAvisBtn_Click(object sender, RoutedEventArgs e) + { + this.SendAvisBtn.IsEnabled = false; + + if (this.PersonnesListView.SelectedIndex < 0 || this.StatutCbbx.SelectedIndex < 0) + { + MessageBox.Show("Veuillez Renseigner tous les champs néccessaires"); + this.SendAvisBtn.IsEnabled = false; + return; + } + + LoadingInd.Visibility = Visibility.Visible; + + Models.AvisRecherche avis = new Models.AvisRecherche() + { + DateEmission = DateTime.Now, + Informations = this.InfosTxtb.Text, + PersonneRecherchee = (this.PersonnesListView.SelectedItem as Models.Personne), + StatutRecherche = StatutCbbx.SelectedItem.ToString(), + }; + + AppLevel.APIClients.AppRestClient2.Authenticator = new JwtAuthenticator( + AppLevel.JWTAuthServices.jwtSvc.TokenizeSessionID( + AppLevel.CachingService.appCache.Get("SessionVM").SessionID, "New Avis")); + + var req = new RestRequest(resource: "AvisRecherche", Method.POST).AddJsonBody(avis); + + var response = await AppLevel.APIClients.AppRestClient2.ExecuteAsync(req); + + + if (response.IsSuccessful) + { + AppLevel.NotificationManagers.ShowNotification("Avis Publié Avec Succès", "Info", AppLevel.NotificationLevel.Info); + } + else + { + AppLevel.NotificationManagers.ShowNotification(response.ResponseStatus.ToString(), "Info", AppLevel.NotificationLevel.Error); + this.SendAvisBtn.IsEnabled = true; + } + + LoadingInd.Visibility = Visibility.Collapsed; + + } + + private async void SearchWdgt_SearchStarted(object sender, HandyControl.Data.FunctionEventArgs e) + { + if (SearchWdgt.Text.Trim() == string.Empty) + { + MessageBox.Show("Veuillez Entrer un mot clé, Nom, Prénom, NPI, IFU...."); + return; + } + + LoadingInd.Visibility = Visibility.Visible; + + AppLevel.APIClients.AppRestClient2.Authenticator = new JwtAuthenticator( + AppLevel.JWTAuthServices.jwtSvc.TokenizeSessionID( + AppLevel.CachingService.appCache.Get("SessionVM").SessionID, "search_for")); + + var Req = new RestRequest(resource: $"Identification/search/{keyword = SearchWdgt.Text}", method: Method.GET); + + var response = await AppLevel.APIClients.AppRestClient2.ExecuteAsync>(request: Req); + + if (response.IsSuccessful) + { + PList = response.Data; + PersonnesListView.ItemsSource = PList; + } + else + { + if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized) + { + AppLevel.NotificationManagers.ShowNotification("Requête Non Authorisée", "Avertissement", AppLevel.NotificationLevel.Warning); + } + else + { + AppLevel.NotificationManagers.ShowNotification("Une Erreur est Survenue", "Erreur", AppLevel.NotificationLevel.Error); + + } + } + + await System.Threading.Tasks.Task.Delay(new TimeSpan(0, 0, 4)); + e.Handled = true; + + LoadingInd.Visibility = Visibility.Collapsed; + } + } +} diff --git a/PoliceOp.OpCenter/MainWindow.xaml b/PoliceOp.OpCenter/MainWindow.xaml index f92aa86..5d98d3e 100644 --- a/PoliceOp.OpCenter/MainWindow.xaml +++ b/PoliceOp.OpCenter/MainWindow.xaml @@ -1,15 +1,17 @@  + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:IconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:Notif="clr-namespace:Enterwell.Clients.Wpf.Notifications.Controls;assembly=Enterwell.Clients.Wpf.Notifications" + xmlns:sys="clr-namespace:System;assembly=mscorlib" + xmlns:hc="https://handyorg.github.io/handycontrol" + mc:Ignorable="d" + Title="OpCenter" TitleCharacterCasing="Normal" TitleAlignment="Center" Height="450" Width="800" + WindowState="Maximized" Icon="/Resources/images/PoliceOp.ico"> + @@ -157,7 +159,7 @@ - - + + - + - + @@ -52,25 +56,21 @@ - + - + -