Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Marat Pavlov
/
AlexAdapter
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
066f641d
authored
Mar 26, 2022
by
Alex Nasyr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
logging added
parent
bf1c81aa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
5 deletions
SocialMinistryDataExchange/Controllers/apiController.cs
SocialMinistryDataExchange/Model/SMRepository.cs
SocialMinistryDataExchange/Controllers/apiController.cs
View file @
066f641d
...
@@ -9,6 +9,7 @@ namespace SocialMinistryDataExchange.Controllers {
...
@@ -9,6 +9,7 @@ namespace SocialMinistryDataExchange.Controllers {
[
ApiController
]
[
ApiController
]
public
class
apiController
:
ControllerBase
{
public
class
apiController
:
ControllerBase
{
private
ISMRepository
_repository
;
private
ISMRepository
_repository
;
public
apiController
(
ISMRepository
repository
)
{
public
apiController
(
ISMRepository
repository
)
{
_repository
=
repository
;
_repository
=
repository
;
}
}
...
...
SocialMinistryDataExchange/Model/SMRepository.cs
View file @
066f641d
...
@@ -3,14 +3,17 @@ using System.Linq;
...
@@ -3,14 +3,17 @@ using System.Linq;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Text.Json
;
using
System.Text.Json
;
using
Microsoft.Extensions.Logging
;
namespace
SocialMinistryDataExchange.Model
{
namespace
SocialMinistryDataExchange.Model
{
public
class
SMRepository
:
ISMRepository
{
public
class
SMRepository
:
ISMRepository
{
private
IContingentContext
_contingentContext
;
private
IContingentContext
_contingentContext
;
private
readonly
ILogger
_logger
;
public
SMRepository
()
{
public
SMRepository
()
{
}
}
public
SMRepository
(
IContingentContext
contingentContext
)
{
public
SMRepository
(
IContingentContext
contingentContext
,
ILogger
<
SMRepository
>
logger
)
{
_contingentContext
=
contingentContext
;
_contingentContext
=
contingentContext
;
_logger
=
logger
;
}
}
public
Task
<
SMDefenceDemandResponce
>
GetPersonDefenceDemandByID
(
string
PersonID
)
{
public
Task
<
SMDefenceDemandResponce
>
GetPersonDefenceDemandByID
(
string
PersonID
)
{
...
@@ -28,6 +31,7 @@ namespace SocialMinistryDataExchange.Model {
...
@@ -28,6 +31,7 @@ namespace SocialMinistryDataExchange.Model {
SMResponce
responce_record
;
SMResponce
responce_record
;
foreach
(
var
doc
in
docs
.
MsgData
)
{
foreach
(
var
doc
in
docs
.
MsgData
)
{
try
{
try
{
// TODO separate exceptions
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
)
{
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
)}
"
);
throw
new
ArgumentNullException
(
$"
{
nameof
(
doc
.
Person
)}
"
);
}
}
...
@@ -70,12 +74,11 @@ namespace SocialMinistryDataExchange.Model {
...
@@ -70,12 +74,11 @@ namespace SocialMinistryDataExchange.Model {
responce_record
=
FormatResponce
(
_contingentContext
,
record
);
responce_record
=
FormatResponce
(
_contingentContext
,
record
);
}
}
catch
(
Exception
ex
)
{
catch
(
Exception
ex
)
{
_logger
.
LogError
(
$"
{
ex
.
Message
}
,
{
ex
.
TargetSite
.
Name
}
,
{
doc
.
Person
}
"
);
// TODO log exception
_logger
.
LogInformation
(
$"creating empty person for doc.seria=
{
doc
.
Person
.
PersonDocumentSeria
}
; doc.number=
{
doc
.
Person
.
PersonDocumentNumber
}
"
);
// TODO separate exceptions
responce_record
=
FormatResponce
(
_contingentContext
,
new
SMResponceTemp
()
{
rowguid_eais
=
doc
.
Person
.
rowguid_eais
,
СерияДокумента
=
doc
.
Person
.
PersonDocumentSeria
,
НомерДокумента
=
doc
.
Person
.
PersonDocumentNumber
});
responce_record
=
FormatResponce
(
_contingentContext
,
new
SMResponceTemp
()
{
rowguid_eais
=
doc
.
Person
.
rowguid_eais
,
СерияДокумента
=
doc
.
Person
.
PersonDocumentSeria
,
НомерДокумента
=
doc
.
Person
.
PersonDocumentNumber
});
}
}
responce
.
Add
(
responce_record
);
responce
.
Add
(
responce_record
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment