This commit is contained in:
FH 2022-04-03 11:20:22 +02:00
parent 9e11d5b33a
commit 896a7a2365
6 changed files with 12 additions and 149 deletions

View file

@ -1,40 +0,0 @@
// ***********************************************************************
// Assembly : FCS.Lib.Virk
// Author : FH
// Created : 01-01-2022
//
// Last Modified By : FH
// Last Modified On : 02-24-2022
// ***********************************************************************
// <copyright file="CvrInfo.cs" company="FCS">
// Copyright (C) 2022 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the Affero GNU General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// Affero GNU General Public License for more details.
//
// You should have received a copy of the Affero GNU General Public License
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
// </copyright>
// <summary></summary>
// ***********************************************************************
namespace FCS.Lib.Virk.CvrModels
{
public class CvrInfo
{
public string VatNumber { get; set; } = "";
public string Name { get; set; } = "";
public string CoName { get; set; } = "";
public string Address { get; set; } = "";
public string City { get; set; } = "";
public string ZipCode { get; set; } = "";
public List<CvrState> States { get; set; } = new();
public List<LifeCycle> LifeCycles { get; set; } = new();
}
}

View file

@ -1,34 +0,0 @@
// ***********************************************************************
// Assembly : FCS.Lib.Virk
// Author : FH
// Created : 01-01-2022
//
// Last Modified By : FH
// Last Modified On : 02-24-2022
// ***********************************************************************
// <copyright file="CvrState.cs" company="FCS">
// Copyright (C) 2022 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the Affero GNU General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// Affero GNU General Public License for more details.
//
// You should have received a copy of the Affero GNU General Public License
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
// </copyright>
// <summary></summary>
// ***********************************************************************
namespace FCS.Lib.Virk.CvrModels
{
public class CvrState
{
public string LastUpdate { get; set; } = "";
public string State { get; set; } = "";
public TimeFrame TimeFrame { get; set; } = new();
}
}

View file

@ -1,34 +0,0 @@
// ***********************************************************************
// Assembly : FCS.Lib.Virk
// Author : FH
// Created : 03-31-2022
//
// Last Modified By : FH
// Last Modified On : 03-31-2022
// ***********************************************************************
// <copyright file="LifeCycle.cs" company="FCS.Lib.Virk">
// Copyright (C) 2022 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see [https://www.gnu.org/licenses]
// </copyright>
// <summary></summary>
// ***********************************************************************
namespace FCS.Lib.Virk.CvrModels
{
public class LifeCycle
{
public string LastUpdate { get; set; } = "";
public TimeFrame TimeFrame { get; set; } = new ();
}
}

View file

@ -1,33 +0,0 @@
// ***********************************************************************
// Assembly : FCS.Lib.Virk
// Author : FH
// Created : 01-01-2022
//
// Last Modified By : FH
// Last Modified On : 02-24-2022
// ***********************************************************************
// <copyright file="TimeFrame.cs" company="FCS">
// Copyright (C) 2022 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the Affero GNU General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// Affero GNU General Public License for more details.
//
// You should have received a copy of the Affero GNU General Public License
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
// </copyright>
// <summary></summary>
// ***********************************************************************
namespace FCS.Lib.Virk.CvrModels
{
public class TimeFrame
{
public string StartDate { get; set; } = "";
public string EndDate { get; set; } = "";
}
}

View file

@ -10,6 +10,9 @@
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\fcs-common\FCS.Lib.Common.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Net.Http" />

View file

@ -24,16 +24,17 @@
// <summary></summary>
// ***********************************************************************
using FCS.Lib.Virk.CvrModels;
using System.Globalization;
using FCS.Lib.Common;
using FCS.Lib.Virk.VrModels;
namespace FCS.Lib.Virk
{
public class VrCvrMapper
public class VrVatInfoMapper
{
public CvrInfo MapVrToCvr(VrVirksomhed vrVirk)
public VatInfoDto MapVrToCvm(VrVirksomhed vrVirk)
{
var c = new CvrInfo
var c = new VatInfoDto
{
Name = vrVirk.VirksomhedMetadata.NyesteNavn.Navn,
Address =
@ -41,12 +42,13 @@ namespace FCS.Lib.Virk
CoName = vrVirk.VirksomhedMetadata.NyesteBeliggenhedsadresse.CoNavn,
ZipCode = vrVirk.VirksomhedMetadata.NyesteBeliggenhedsadresse.Postnummer.ToString(),
City = vrVirk.VirksomhedMetadata.NyesteBeliggenhedsadresse.PostDistrikt,
VatNumber = vrVirk.CvrNummer
VatNumber = vrVirk.CvrNummer,
RequestDate = DateTime.Now.ToString(CultureInfo.InvariantCulture)
};
if (vrVirk.VirksomhedsStatus.Any())
{
foreach (var cs in vrVirk.VirksomhedsStatus.Select(vrStatus => new CvrState
foreach (var cs in vrVirk.VirksomhedsStatus.Select(vrStatus => new VatState
{
State = vrStatus.Status,
LastUpdate = vrStatus.SidstOpdateret,
@ -62,7 +64,7 @@ namespace FCS.Lib.Virk
}
else
{
c.States.Add(new CvrState());
c.States.Add(new VatState());
}
if (vrVirk.Livsforloeb.Any())
@ -94,7 +96,6 @@ namespace FCS.Lib.Virk
c.States[sc].LastUpdate = c.LifeCycles[lcc].LastUpdate;
c.States[sc].TimeFrame.StartDate = c.LifeCycles[lcc].TimeFrame.StartDate;
c.States[sc].TimeFrame.EndDate = c.LifeCycles[lcc].TimeFrame.EndDate;
c.States[sc].State = string.IsNullOrWhiteSpace(c.LifeCycles[c.LifeCycles.Count - 1].TimeFrame.EndDate) ? "NORMAL" : "LUKKET";
return c;
}