GetAllContacts from EFCore

pull/1/head
DJh2o2 2022-11-17 11:57:28 +07:00
parent ffba8f0fc5
commit 7eea349104
9 changed files with 261 additions and 255 deletions

@ -3,19 +3,13 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33103.201
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gremlin_CaliburnMicro", "Gremlin\Gremlin_CaliburnMicro.csproj", "{4CF01C42-DA2E-4380-B237-35F27DD2FDED}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{569617CF-74C2-4C2C-89DD-18CC88BE29C3}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.editorconfig.inferred = .editorconfig.inferred
EndProjectSection
EndProject
Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "Gremlin_Python", "Gremlin_Python\Gremlin_Python.pyproj", "{9E0CF057-C3D7-4F60-A4EC-93E712610B53}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gremlin_Blazor", "Gremlin_Blazor\Gremlin_Blazor.csproj", "{294A4101-02EF-4D17-A2FF-E1C0ADDC75D0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gremlin_BlazorServer", "Gremlin_BlazorServer\Gremlin_BlazorServer.csproj", "{09D55D87-9321-4F01-8E29-A5043FF07CD4}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gremlin_BlazorServer", "Gremlin_BlazorServer\Gremlin_BlazorServer.csproj", "{09D55D87-9321-4F01-8E29-A5043FF07CD4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -23,16 +17,6 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4CF01C42-DA2E-4380-B237-35F27DD2FDED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4CF01C42-DA2E-4380-B237-35F27DD2FDED}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4CF01C42-DA2E-4380-B237-35F27DD2FDED}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4CF01C42-DA2E-4380-B237-35F27DD2FDED}.Release|Any CPU.Build.0 = Release|Any CPU
{9E0CF057-C3D7-4F60-A4EC-93E712610B53}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9E0CF057-C3D7-4F60-A4EC-93E712610B53}.Release|Any CPU.ActiveCfg = Release|Any CPU
{294A4101-02EF-4D17-A2FF-E1C0ADDC75D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{294A4101-02EF-4D17-A2FF-E1C0ADDC75D0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{294A4101-02EF-4D17-A2FF-E1C0ADDC75D0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{294A4101-02EF-4D17-A2FF-E1C0ADDC75D0}.Release|Any CPU.Build.0 = Release|Any CPU
{09D55D87-9321-4F01-8E29-A5043FF07CD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{09D55D87-9321-4F01-8E29-A5043FF07CD4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{09D55D87-9321-4F01-8E29-A5043FF07CD4}.Release|Any CPU.ActiveCfg = Release|Any CPU

@ -1,21 +1,14 @@
// using DocumentFormat.OpenXml.Packaging;
// using DocumentFormat.OpenXml.Wordprocessing;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
using Gremlin_BlazorServer.Data.EntityClasses;
using Gremlin_BlazorServer.Utilities;
using Microsoft.EntityFrameworkCore;
using Microsoft.VisualBasic.FileIO;
using MySqlConnector;
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using static Gremlin_BlazorServer.Data.EntityClasses.Enums;
namespace Gremlin_BlazorServer.Data.DBClasses
@ -1332,157 +1325,157 @@ namespace Gremlin_BlazorServer.Data.DBClasses
}
}
public static bool ImportCustomDescriptionsFromDocx(string filepath = "")
///Importiert Eigene Beschreibungen aus Word-Dokument
///Abkürzung: CD = CustomDescriptions
{
if (filepath == "")
{
//filepath = FileIO.GetFilepathFromUser("Word-Dokument|*.doc; *.docx; *.docm"); //Pfad abfragen über Dtei-Öffnen-Dialog:
}
if (filepath == "")
{
return false; //Wenn keine Datei ausgewählt (Cancel geklickt), dann Abbruch:
}
List<CustomDescription> importedCDs = new(2500);
WordprocessingDocument CDDoc = WordprocessingDocument.Open(filepath, false); //alternativ in using-Block packen, dann kann man nicht das Document.Close vergessen.
Table CDTable = CDDoc.MainDocumentPart.Document.Body.Elements<Table>().ElementAt(0); //alternativ: Elements<Table>.First()
if (CDTable != null)
{
CDTable.Descendants<TableRow>().First().Remove(); //Überschriften löschen
foreach (TableRow aRow in CDTable.Descendants<TableRow>()) //einmal durch den XML-Baum wandern: WordprocessingDocument -> MainDocumentPart -> Document -> Body -> Table -> TableRow -> TableCell -> Paragraph -> Run -> Text
{
CustomDescription importedCD = new();
List<string> stringsRead = new();
foreach (TableCell aCell in aRow.Descendants<TableCell>())
{
StringBuilder sb = new();
StringBuilder note = new();
foreach (Paragraph aParagraph in aCell.Descendants<Paragraph>())
{
foreach (Run aRun in aParagraph.Descendants<Run>())
{
foreach (Text aText in aRun.Descendants<Text>())
{
string temp = "";
temp = aParagraph.Descendants<Run>()
.Where(r => r.RunProperties.Vanish != null)
.Aggregate("", (text, r) => text += r.InnerText); //nach hidden Text filtern, diesen in "note" speichern
_ = note.Append(temp);
if (temp == "") //true, falls kein hidden Text => normalen Text verketten...
{
_ = sb.Append(aText.InnerText);
}
}
}
}
stringsRead.Add(sb.ToString()); //...und zellenweise abspeichern
if (note.ToString() != "")
{
importedCD.Notes = note.ToString();
}
}
importedCD.ProductNumber = stringsRead.ElementAt(0);
importedCD.OptionNumber = stringsRead.ElementAt(1) == "" ? null : stringsRead.ElementAt(1);
importedCD.Supplier.AccountName = stringsRead.ElementAt(2) is "" or "RB" ? "Agilent Technologies" : stringsRead.ElementAt(2);
importedCD.Heading = stringsRead.ElementAt(3);
importedCD.DescriptionText = stringsRead.ElementAt(4);
importedCD.CoverletterText = stringsRead.ElementAt(5);
importedCDs.Add(importedCD);
//if (importedCDs.Count >= 1200 && importedCDs.Count % 100 == 0) MessageBox.Show(importedCDs.Count.ToString()); //DEBUGGING
}
}
//MessageBox.Show(importedCDs.Count.ToString()); //DEBUGGING
CDDoc.Close();
//Eingelesenen Custum Desciptions in DB schreiben:
//Check for 3PPs that not yet in the db.
//Step 1a: Add 3PP-Products from CD-List to list
//Step 1b: Add list to db.
//Step 2: Add CDs to products.
using (GremlinContext db = new())
{
//Step 1a
List<Product> thirdPartyProductsFromImportedCDs = new();
foreach (CustomDescription CD in importedCDs)
{
if (CD.Supplier.AccountName != "Agilent Technologies")
{
Product new3PPProduct = new()
{
CustomDescription = CD,
HasBreakPrices = false,
ListPrice = 0,
ProductNumber = CD.ProductNumber,
OptionNumber = CD.OptionNumber,
ProductStatus = Status.Active.ToString(),
SapLongDescription = null,
SapShortDescription = null,
Weight = 0,
IntroductionDate = DateTime.Now.Date,
BreakRangeFrom = 0,
BreakRangeTo = 0,
ProductLine = ResolveProductLine(db, "3P")
};
new3PPProduct.CustomDescription.Supplier = ResolveAccountByName(db, new3PPProduct.CustomDescription.Supplier.AccountName);
_ = MetaDataSetter.ForImport(new3PPProduct, "Custom Desciption Importer", "Created at import from Custom Descriptions.");
thirdPartyProductsFromImportedCDs.Add(new3PPProduct);
}
};
//Step 1b
db.Products.AddRange(thirdPartyProductsFromImportedCDs); //Imports both the products and the associated custom descriptions!
_ = db.SaveChanges();
// Produkt aus DB laden, damit der Datensatz vom Context verfolgt wird und EF Core nicht versucht, diesen standardmäßig neu anzulegen.
//Step 2
List<CustomDescription> importedCDsWithEFReferences = new();
List<CustomDescription> CDsWithoutEFReferences = new(); //nur zur Kontrolle, wird nicht verwendet.
foreach (CustomDescription CD in importedCDs)
{
//Skip Desciptions, if it has been already imported above (as part from 3PP)
if (thirdPartyProductsFromImportedCDs.Intersect(CD.Products).Any())
{
continue;
}
//Establish EF Reference. If no PN/Opt found, then skip this custom description.
CD.Products.Add(ResolveProduct(db, CD.ProductNumber, CD.OptionNumber)); //ResolveXY-functions return null, if no match is found in db.
if (CD.Products == null)
{
CDsWithoutEFReferences.Add(CD);
continue;
}
//Establish EF Reference. If no Supplier-Account found, then skip this custom description.
CD.Supplier = ResolveAccountByName(db, CD.Supplier.AccountName); //ResolveXY-functions return null, if no match is found in db.
if (CD.Supplier == null)
{
CDsWithoutEFReferences.Add(CD);
continue;
}
_ = MetaDataSetter.ForImport(CD, "DocxImporter", "Initial import by CSV Importer (Function DbHelper.ImportCustomDescriptionsFromDocx)");
//add to final list of CDs, that will go into the db.
importedCDsWithEFReferences.Add(CD);
}
db.CustomDescriptions.AddRange(importedCDsWithEFReferences);
_ = db.SaveChanges();
}
return true;
}
//public static bool ImportCustomDescriptionsFromDocx(string filepath = "")
/////Importiert Eigene Beschreibungen aus Word-Dokument
/////Abkürzung: CD = CustomDescriptions
//{
// if (filepath == "")
// {
// //filepath = FileIO.GetFilepathFromUser("Word-Dokument|*.doc; *.docx; *.docm"); //Pfad abfragen über Dtei-Öffnen-Dialog:
// }
// if (filepath == "")
// {
// return false; //Wenn keine Datei ausgewählt (Cancel geklickt), dann Abbruch:
// }
// List<CustomDescription> importedCDs = new(2500);
// WordprocessingDocument CDDoc = WordprocessingDocument.Open(filepath, false); //alternativ in using-Block packen, dann kann man nicht das Document.Close vergessen.
// Table CDTable = CDDoc.MainDocumentPart.Document.Body.Elements<Table>().ElementAt(0); //alternativ: Elements<Table>.First()
// if (CDTable != null)
// {
// CDTable.Descendants<TableRow>().First().Remove(); //Überschriften löschen
// foreach (TableRow aRow in CDTable.Descendants<TableRow>()) //einmal durch den XML-Baum wandern: WordprocessingDocument -> MainDocumentPart -> Document -> Body -> Table -> TableRow -> TableCell -> Paragraph -> Run -> Text
// {
// CustomDescription importedCD = new();
// List<string> stringsRead = new();
// foreach (TableCell aCell in aRow.Descendants<TableCell>())
// {
// StringBuilder sb = new();
// StringBuilder note = new();
// foreach (Paragraph aParagraph in aCell.Descendants<Paragraph>())
// {
// foreach (Run aRun in aParagraph.Descendants<Run>())
// {
// foreach (Text aText in aRun.Descendants<Text>())
// {
// string temp = "";
// temp = aParagraph.Descendants<Run>()
// .Where(r => r.RunProperties.Vanish != null)
// .Aggregate("", (text, r) => text += r.InnerText); //nach hidden Text filtern, diesen in "note" speichern
// _ = note.Append(temp);
// if (temp == "") //true, falls kein hidden Text => normalen Text verketten...
// {
// _ = sb.Append(aText.InnerText);
// }
// }
// }
// }
// stringsRead.Add(sb.ToString()); //...und zellenweise abspeichern
// if (note.ToString() != "")
// {
// importedCD.Notes = note.ToString();
// }
// }
// importedCD.ProductNumber = stringsRead.ElementAt(0);
// importedCD.OptionNumber = stringsRead.ElementAt(1) == "" ? null : stringsRead.ElementAt(1);
// importedCD.Supplier.AccountName = stringsRead.ElementAt(2) is "" or "RB" ? "Agilent Technologies" : stringsRead.ElementAt(2);
// importedCD.Heading = stringsRead.ElementAt(3);
// importedCD.DescriptionText = stringsRead.ElementAt(4);
// importedCD.CoverletterText = stringsRead.ElementAt(5);
// importedCDs.Add(importedCD);
// //if (importedCDs.Count >= 1200 && importedCDs.Count % 100 == 0) MessageBox.Show(importedCDs.Count.ToString()); //DEBUGGING
// }
// }
// //MessageBox.Show(importedCDs.Count.ToString()); //DEBUGGING
// CDDoc.Close();
// //Eingelesenen Custum Desciptions in DB schreiben:
// //Check for 3PPs that not yet in the db.
// //Step 1a: Add 3PP-Products from CD-List to list
// //Step 1b: Add list to db.
// //Step 2: Add CDs to products.
// using (GremlinContext db = new())
// {
// //Step 1a
// List<Product> thirdPartyProductsFromImportedCDs = new();
// foreach (CustomDescription CD in importedCDs)
// {
// if (CD.Supplier.AccountName != "Agilent Technologies")
// {
// Product new3PPProduct = new()
// {
// CustomDescription = CD,
// HasBreakPrices = false,
// ListPrice = 0,
// ProductNumber = CD.ProductNumber,
// OptionNumber = CD.OptionNumber,
// ProductStatus = Status.Active.ToString(),
// SapLongDescription = null,
// SapShortDescription = null,
// Weight = 0,
// IntroductionDate = DateTime.Now.Date,
// BreakRangeFrom = 0,
// BreakRangeTo = 0,
// ProductLine = ResolveProductLine(db, "3P")
// };
// new3PPProduct.CustomDescription.Supplier = ResolveAccountByName(db, new3PPProduct.CustomDescription.Supplier.AccountName);
// _ = MetaDataSetter.ForImport(new3PPProduct, "Custom Desciption Importer", "Created at import from Custom Descriptions.");
// thirdPartyProductsFromImportedCDs.Add(new3PPProduct);
// }
// };
// //Step 1b
// db.Products.AddRange(thirdPartyProductsFromImportedCDs); //Imports both the products and the associated custom descriptions!
// _ = db.SaveChanges();
// // Produkt aus DB laden, damit der Datensatz vom Context verfolgt wird und EF Core nicht versucht, diesen standardmäßig neu anzulegen.
// //Step 2
// List<CustomDescription> importedCDsWithEFReferences = new();
// List<CustomDescription> CDsWithoutEFReferences = new(); //nur zur Kontrolle, wird nicht verwendet.
// foreach (CustomDescription CD in importedCDs)
// {
// //Skip Desciptions, if it has been already imported above (as part from 3PP)
// if (thirdPartyProductsFromImportedCDs.Intersect(CD.Products).Any())
// {
// continue;
// }
// //Establish EF Reference. If no PN/Opt found, then skip this custom description.
// CD.Products.Add(ResolveProduct(db, CD.ProductNumber, CD.OptionNumber)); //ResolveXY-functions return null, if no match is found in db.
// if (CD.Products == null)
// {
// CDsWithoutEFReferences.Add(CD);
// continue;
// }
// //Establish EF Reference. If no Supplier-Account found, then skip this custom description.
// CD.Supplier = ResolveAccountByName(db, CD.Supplier.AccountName); //ResolveXY-functions return null, if no match is found in db.
// if (CD.Supplier == null)
// {
// CDsWithoutEFReferences.Add(CD);
// continue;
// }
// _ = MetaDataSetter.ForImport(CD, "DocxImporter", "Initial import by CSV Importer (Function DbHelper.ImportCustomDescriptionsFromDocx)");
// //add to final list of CDs, that will go into the db.
// importedCDsWithEFReferences.Add(CD);
// }
// db.CustomDescriptions.AddRange(importedCDsWithEFReferences);
// _ = db.SaveChanges();
// }
// return true;
//}
public static bool UpdateProductsFromCsv(string filepath = "", string separator = "|", bool dataHasHeading = true)
{
@ -2023,10 +2016,10 @@ namespace Gremlin_BlazorServer.Data.DBClasses
return await Task.Run(() => ImportProductsFromCsv());
}
public static async Task<bool> ImportCustomDescriptionsFromDocxAsync()
{
return await Task.Run(() => ImportCustomDescriptionsFromDocx());
}
//public static async Task<bool> ImportCustomDescriptionsFromDocxAsync()
//{
// return await Task.Run(() => ImportCustomDescriptionsFromDocx());
//}
public static async Task<bool> ImportCustomDescriptionsFromCsvAsync()
{
@ -2091,5 +2084,23 @@ namespace Gremlin_BlazorServer.Data.DBClasses
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
return new string(Enumerable.Repeat(chars, length).Select(s => s[random.Next(s.Length)]).ToArray());
}
public static Contact GetContact(GremlinContext context, string lastName)
{
try { return context.Contacts.Where(contact => contact.LastName == lastName).First(); }
catch { return null; }
}
public static Contact GetContact(GremlinContext context, uint contactId)
{
try { return context.Contacts.Where(contact => contact.ContactId == contactId).First(); }
catch { return null; }
}
internal static List<Contact> GetAllContacts(GremlinContext context)
{
try { return context.Contacts.Where(contact => contact.LastName != "").ToList(); }
catch { return null; }
}
}
}

@ -29,11 +29,11 @@ namespace Gremlin_BlazorServer.Data.DBClasses
string connectionString = $"server=woitschetzki.de;" +
$"port=3306;" +
$"database=Regulus;" +
$"user=sascha;" +
$"password=mgltoJtmmDnKJ86LltsGdw;" +
$"SslMode=No;" +
$"SslCa=None";
$"database=regulus;" +
$"user=root;" +
$"password=lungretter1;" +
$"SslMode=;" +
$"SslCa=";
try
{

@ -0,0 +1,21 @@
using Gremlin_BlazorServer.Data.DBClasses;
using Gremlin_BlazorServer.Data.EntityClasses;
using Gremlin_BlazorServer.ViewModels;
namespace Gremlin_BlazorServer.Models
{
public class AccountModel
{
internal static AccountViewModel GetAccountViewModel(uint accountId)
{
GremlinContext gremlinContext = new();
Account account = DbHelper.ResolveAccountById(gremlinContext, accountId);
return ConvertAccountToAccountVM(account);
}
private static AccountViewModel ConvertAccountToAccountVM(Account account)
{
return new(account.AccountName, account.Street,account.ZIP,account.City,account.AccountType.AccountTypeCode);
}
}
}

@ -1,55 +1,50 @@
using Gremlin_BlazorServer.Data.EntityClasses;
using Gremlin_BlazorServer.Data.DBClasses;
using Gremlin_BlazorServer.Data.EntityClasses;
using Gremlin_BlazorServer.ViewModels;
// using System.Windows.Data;
namespace Gremlin_BlazorServer.Models
{
public class ContactModel
{
public static ContactViewModel ConvertContactToContactVM(Contact contact)
internal static async Task<List<ContactViewModel>> GetContactViewModel()
{
if (contact.Account != null)
{
ContactViewModel contactVM = new()
{
ContactId = contact.ContactId,
Gender = contact.Gender,
LastName = contact.LastName,
FirstName = contact.FirstName,
EMail = contact.EMail,
AccountId = contact.AccountId
//AccountName = contact.Account.AccountName,
//AccountStreet = contact.Account.Street,
//AccountZIP = contact.Account.ZIP,
//AccountCity = contact.Account.City,
//AccountTypeCode = contact.Account.AccountType.AccountTypeCode
};
return contactVM;
}
else
{
ErrorHandler.ShowErrorMessage($"Kontakt {contact.LastName} hat keinen Account!");
return null;
}
GremlinContext gremlinContext = new();
List<Contact> contacts = DbHelper.GetAllContacts(gremlinContext);
return await ConvertContactToContactVM(contacts);
}
public static ContactViewModel ConvertObjectToContactVM(object selectedItem)
internal static ContactViewModel GetContactViewModel(string lastName)
{
ContactViewModel selectedContact = new();
GremlinContext gremlinContext = new();
Contact contact = DbHelper.GetContact(gremlinContext, lastName);
return ConvertContactToContactVM(contact);
}
//if (selectedItem != CollectionView.NewItemPlaceholder)
//{
// //TryCast
// selectedContact = selectedItem as ContactViewModel;
internal static ContactViewModel GetContactViewModel(uint contactId)
{
GremlinContext gremlinContext = new();
Contact contact = DbHelper.GetContact(gremlinContext, contactId);
return ConvertContactToContactVM(contact);
}
// //if failed == null
// if (selectedContact == null)
// {
// return default;
// }
//}
public static ContactViewModel ConvertContactToContactVM(Contact contact)
{
return new(contact.ContactId, contact.AccountId, contact.LastName, contact.FirstName, contact.Gender, contact.EMail);
}
public static async Task<List<ContactViewModel>> ConvertContactToContactVM(List<Contact> contacts)
{
List<ContactViewModel> contactsVM = new();
return selectedContact;
if (contacts != null)
{
foreach (Contact contact in contacts)
{
ContactViewModel contactVM = new(contact.ContactId, contact.AccountId, contact.LastName, contact.FirstName, contact.Gender, contact.EMail);
contactsVM.Add(contactVM);
}
}
return contactsVM;
}
}
}

@ -1,4 +1,5 @@
@page "/contacts"
@using Gremlin_BlazorServer.Data.DBClasses;
@using Gremlin_BlazorServer.Services;
@using Gremlin_BlazorServer.Models;
@using Gremlin_BlazorServer.ViewModels;
@ -57,7 +58,8 @@ else
protected override async Task OnInitializedAsync()
{
allContacts = await DataAccessService.GetContactsFromDb("");
allContacts = await ContactModel.GetContactViewModel();
//allContacts = await DataAccessService.GetContactsFromDb("");
}
private void SearchContact_OnChange()

@ -48,29 +48,28 @@ namespace Gremlin_BlazorServer.Utilities
_ = briefkopf.AppendLine($"\\\\");
}
AccountViewModel account = contactVM.GetAccount();
string AccountName = account.AccountName;
AccountViewModel accountVM = AccountModel.GetAccountViewModel(contactVM.AccountId);
//AccountNamen mit "&" im Namen abfangen
if (tex && AccountName.Contains('&'))
if (tex && accountVM.AccountName.Contains('&'))
{
string[] accountNameSplit = AccountName.Split("&"); //.Replace?
AccountName = "";
string[] accountNameSplit = accountVM.AccountName.Split("&"); //.Replace?
accountVM.AccountName = "";
for (int i = 0; i < accountNameSplit.Length; i++)
{
AccountName += i < accountNameSplit.Length - 1
accountVM.AccountName += i < accountNameSplit.Length - 1
? accountNameSplit[i] + "\\&"
: accountNameSplit[i];
}
}
_ = briefkopf.AppendLine($"{AccountName}");
_ = briefkopf.AppendLine($"{accountVM.AccountName}");
if (tex) { _ = briefkopf.AppendLine($"\\\\"); }
_ = briefkopf.AppendLine($"{contactVM.Account.AccountStreet}");
_ = briefkopf.AppendLine($"{accountVM.AccountStreet}");
if (tex) { _ = briefkopf.AppendLine($"\\\\"); }
_ = briefkopf.AppendLine($"{contactVM.Account.AccountZIP} {contactVM.Account.AccountCity}");
_ = briefkopf.AppendLine($"{accountVM.AccountZIP} {accountVM.AccountCity}");
if (tex) { _ = briefkopf.AppendLine($"\\\\"); }
return briefkopf;

@ -1,14 +1,20 @@
using Gremlin_BlazorServer.Data.EntityClasses;
namespace Gremlin_BlazorServer.ViewModels
namespace Gremlin_BlazorServer.ViewModels
{
public class AccountViewModel
{
{
public string AccountName { get; set; }
public string AccountStreet { get; set; }
public int AccountZIP { get; set; }
public uint AccountZIP { get; set; }
public string AccountCity { get; set; }
public string AccountTypeCode { get; set; }
public AccountViewModel(string accountName, string accountStreet, uint accountZIP, string accountCity, string accountTypeCode)
{
AccountName = accountName ?? throw new ArgumentNullException(nameof(accountName));
AccountStreet = accountStreet ?? throw new ArgumentNullException(nameof(accountStreet));
AccountZIP = accountZIP;
AccountCity = accountCity ?? throw new ArgumentNullException(nameof(accountCity));
AccountTypeCode = accountTypeCode ?? throw new ArgumentNullException(nameof(accountTypeCode));
}
}
}

@ -1,7 +1,4 @@
using Gremlin_BlazorServer.Data.EntityClasses;
using Gremlin_BlazorServer.Models;
namespace Gremlin_BlazorServer.ViewModels
namespace Gremlin_BlazorServer.ViewModels
{
public class ContactViewModel
{
@ -11,26 +8,17 @@ namespace Gremlin_BlazorServer.ViewModels
public string LastName { get; set; }
public byte Gender { get; set; }
public string EMail { get; set; }
public AccountViewModel Account { get; set; }
public ContactViewModel(uint contactId, uint accountId, string firstName, string lastName, byte gender, string eMail)
{
ContactId = contactId;
AccountId = accountId; //Account.GetAccount(accountId);
AccountId = accountId;
FirstName = firstName ?? throw new ArgumentNullException(nameof(firstName));
LastName = lastName ?? throw new ArgumentNullException(nameof(lastName));
Gender = gender;
EMail = eMail ?? throw new ArgumentNullException(nameof(eMail));
Account = GetAccount();
}
public ContactViewModel()
{
}
public AccountViewModel GetAccount()
{
return new AccountViewModel();
}
public ContactViewModel() { }
}
}