Add project files.

This commit is contained in:
2021-05-09 22:10:25 +02:00
parent f20ba23e7b
commit f8c472a4cd
70 changed files with 6207 additions and 0 deletions

View File

@ -0,0 +1,55 @@
using DataDomain;
using DatamodelLibrary;
using StockDAL.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StockDAL
{
public class AddressRepository : IAddressRepository
{
public Address GetAddressById(int AddressId)
{
using var context = new StockContext();
var entity = (from adr in context.Addresses
where adr.Id == AddressId
select adr).FirstOrDefault();
return entity;
}
public Address SaveAddress(Address address)
{
using var context = new StockContext();
var entity = (from adr in context.Addresses
where adr.Id == address.Id
select adr).FirstOrDefault();
if (entity == null)
{
entity = new Address
{
Street = address.Street,
Street2 = address.Street2,
Zipcode = address.Zipcode,
Destination = address.Destination,
Nation = address.Nation
};
context.Addresses.Add(entity);
}
else
{
entity.Street = address.Street;
entity.Street2 = address.Street2;
entity.Zipcode = address.Zipcode;
entity.Destination = address.Destination;
entity.Nation = address.Nation;
}
context.SaveChanges();
return entity;
}
}
}