From 896a7a23654cd245b879bcd667207208ce1a3166 Mon Sep 17 00:00:00 2001 From: FH Date: Sun, 3 Apr 2022 11:20:22 +0200 Subject: [PATCH] refactor --- CvrModels/CvrInfo.cs | 40 ---------------------------- CvrModels/CvrState.cs | 34 ----------------------- CvrModels/LifeCycle.cs | 34 ----------------------- CvrModels/TimeFrame.cs | 33 ----------------------- FCS.Lib.Virk.csproj | 3 +++ VrCvrMapper.cs => VrVatInfoMapper.cs | 17 ++++++------ 6 files changed, 12 insertions(+), 149 deletions(-) delete mode 100644 CvrModels/CvrInfo.cs delete mode 100644 CvrModels/CvrState.cs delete mode 100644 CvrModels/LifeCycle.cs delete mode 100644 CvrModels/TimeFrame.cs rename VrCvrMapper.cs => VrVatInfoMapper.cs (91%) diff --git a/CvrModels/CvrInfo.cs b/CvrModels/CvrInfo.cs deleted file mode 100644 index 2ed9a5a..0000000 --- a/CvrModels/CvrInfo.cs +++ /dev/null @@ -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 (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] -// -// -// *********************************************************************** - -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 States { get; set; } = new(); - public List LifeCycles { get; set; } = new(); - } -} \ No newline at end of file diff --git a/CvrModels/CvrState.cs b/CvrModels/CvrState.cs deleted file mode 100644 index cfe3dd3..0000000 --- a/CvrModels/CvrState.cs +++ /dev/null @@ -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 (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] -// -// -// *********************************************************************** -namespace FCS.Lib.Virk.CvrModels -{ - public class CvrState - { - public string LastUpdate { get; set; } = ""; - public string State { get; set; } = ""; - public TimeFrame TimeFrame { get; set; } = new(); - } -} \ No newline at end of file diff --git a/CvrModels/LifeCycle.cs b/CvrModels/LifeCycle.cs deleted file mode 100644 index c40c325..0000000 --- a/CvrModels/LifeCycle.cs +++ /dev/null @@ -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 (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] -// -// -// *********************************************************************** -namespace FCS.Lib.Virk.CvrModels -{ - public class LifeCycle - { - public string LastUpdate { get; set; } = ""; - public TimeFrame TimeFrame { get; set; } = new (); - - } -} \ No newline at end of file diff --git a/CvrModels/TimeFrame.cs b/CvrModels/TimeFrame.cs deleted file mode 100644 index 3ae7c78..0000000 --- a/CvrModels/TimeFrame.cs +++ /dev/null @@ -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 (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] -// -// -// *********************************************************************** -namespace FCS.Lib.Virk.CvrModels -{ - public class TimeFrame - { - public string StartDate { get; set; } = ""; - public string EndDate { get; set; } = ""; - } -} \ No newline at end of file diff --git a/FCS.Lib.Virk.csproj b/FCS.Lib.Virk.csproj index 13c906f..726c37c 100644 --- a/FCS.Lib.Virk.csproj +++ b/FCS.Lib.Virk.csproj @@ -10,6 +10,9 @@ + + + diff --git a/VrCvrMapper.cs b/VrVatInfoMapper.cs similarity index 91% rename from VrCvrMapper.cs rename to VrVatInfoMapper.cs index ee25248..173929a 100644 --- a/VrCvrMapper.cs +++ b/VrVatInfoMapper.cs @@ -24,16 +24,17 @@ // // *********************************************************************** -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; }