Commit 94a7fc86 by AlexNasyr

transit

parent b28ec718
......@@ -20,7 +20,13 @@ namespace SocialMinistryDataExchange.Controllers {
var msg = new SMPersonDataRequest() {
MsgID = "123",
MsgDataTime = DateTime.Now,
MsgData = new SMPersonDataOccupationMessage[] { new SMPersonDataOccupationMessage() { Person = new Person() { rowguid_eais = "223322", PersonDocumentSeria = "V-II", PersonDocumentNumber = "123456" }, PersonOccupation = new SMPersonOccupation(), Error = "" } }
MsgData = new SMPersonDataOccupationMessage[] { new SMPersonDataOccupationMessage() {
Person = new Person() {
rowguid_eais = "223322",
PersonDocumentSeria = "V-II",
PersonDocumentNumber = "123456"
},
PersonOccupation = new SMPersonOccupation(), Error = "" } }
};
var result = await _repository.GetPersonByDoc(JsonSerializer.Serialize(msg));
//var result = await _repository.GetPersonByDoc(JsonSerializer.Serialize(new List<SMPersonRequest>() { new SMPersonRequest() { rowguid_eais = "223322", document_seria = "V-II", document_number = "123456" }, new SMPersonRequest() { rowguid_eais = "322223", document_seria = "1234", document_number = "123456" } }));
......
......@@ -24,13 +24,20 @@ namespace SocialMinistryDataExchange.Model {
public Task<List<SMResponce>> GetPersonByDoc(string document) {
var docs = JsonSerializer.Deserialize<SMPersonDataRequest>(document);
List<SMResponce> responce = new();
SMResponce responce_record;
foreach (var doc in docs.MsgData) {
SMResponce responce_record = new SMResponce();
try {
if (doc.Person.PersonDocumentSeria is null || doc.Person.PersonDocumentNumber is null || doc.Person.PersonFamilyName is null || doc.Person.PersonName is null || doc.Person.PersonBirthday is null) {
throw new ArgumentNullException($"{nameof(doc.Person)}");
}
responce_record = new SMResponce();
var record = (from pd in _contingentContext.ДокументЛичностиs
where pd.СерияДокумента == doc.Person.PersonDocumentSeria && pd.НомерДокумента == doc.Person.PersonDocumentNumber
&& pd.ЛичностьNavigation.Фамилия == doc.Person.PersonFamilyName && pd.ЛичностьNavigation.Имя == doc.Person.PersonName
&& (pd.ЛичностьNavigation.БезОтчества == false & pd.ЛичностьNavigation.Отчество == doc.Person.PersonSurname) && pd.ЛичностьNavigation.ДатаРождения == doc.Person.PersonBirthday
where pd.СерияДокумента == doc.Person.PersonDocumentSeria && pd.НомерДокумента == doc.Person.PersonDocumentNumber
&& pd.ЛичностьNavigation.Фамилия == doc.Person.PersonFamilyName && pd.ЛичностьNavigation.Имя == doc.Person.PersonName
&& (pd.ЛичностьNavigation.БезОтчества == false & pd.ЛичностьNavigation.Отчество == doc.Person.PersonSurname)
&& pd.ЛичностьNavigation.ДатаРождения == doc.Person.PersonBirthday
join lp in _contingentContext.ЛичностьПодразделенияs on pd.Личность equals lp.Личность into lps
from lp in lps.DefaultIfEmpty()
join op in _contingentContext.ОбразовательнаяПрограммаОрганизацииs on lp.Организация equals op.Организация into ops
......@@ -59,18 +66,16 @@ namespace SocialMinistryDataExchange.Model {
// ФормаОбученияКод, ФормаОбученияНаименование
, ФормаОбученияКод = cp.ФормаОбученияNavigation.Код, ФормаОбученияНаименование = cp.ФормаОбученияNavigation.Наименование
}).First();
// записи не найдены
if (record == null) {
record = new SMResponceTemp() { rowguid_eais = doc.Person.rowguid_eais, СерияДокумента = doc.Person.PersonDocumentSeria, НомерДокумента = doc.Person.PersonDocumentNumber };
}
responce_record = FormatResponce(_contingentContext, record);
}
catch (Exception ex) {
// TODO log exception
// TODO separate exceptions
responce_record = FormatResponce(_contingentContext, new SMResponceTemp() { rowguid_eais = doc.Person.rowguid_eais, СерияДокумента = doc.Person.PersonDocumentSeria, НомерДокумента = doc.Person.PersonDocumentNumber });
}
responce.Add(responce_record);
}
return Task.FromResult(responce);
......
......@@ -53,11 +53,11 @@ namespace SocialMinistryDataExchange.Model {
public string PersonFamilyName { get; set; }
public string PersonName { get; set; }
public string? PersonSurname { get; set; }
public DateTime PersonBirthday { get; set; }
public DateTime? PersonBirthday { get; set; }
public int PersonDocumentType { get; set; }
public string PersonDocumentSeria { get; set; }
public string PersonDocumentNumber { get; set; }
public DateTime PersonDocumentDate { get; set; }
public DateTime? PersonDocumentDate { get; set; }
public string? PersonSnils { get; set; }
public string? PersonAddress { get; set; }
public string? DependentPerson { get; set; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment