added COA packages, added mapping profiles, updated creditor fields
This commit is contained in:
parent
4630b54fd2
commit
be0bc54bb9
@ -5,6 +5,10 @@
|
||||
<AssemblyName>COA.EnterpriseServices.Creditors</AssemblyName>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DataObjects" Version="20.10.2.3-alpha" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\COA.EnterpriseServices.DataAccess\COA.EnterpriseServices.DataAccess.csproj" />
|
||||
</ItemGroup>
|
||||
|
@ -19,9 +19,9 @@
|
||||
return creditorLibrary.SetCreditorStatus(creditorId, status);
|
||||
}
|
||||
|
||||
public void AddOfferResponse()
|
||||
public void AddOfferResponse(OfferResponse response)
|
||||
{
|
||||
creditorLibrary.AddOfferResponse();
|
||||
creditorLibrary.AddOfferResponse(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ namespace COA.EnterpriseServices.Creditors
|
||||
{
|
||||
var creditor = creditorHelper.GetCreditor(creditorId);
|
||||
|
||||
return creditor.Status;
|
||||
return creditor.creditorStatus;
|
||||
}
|
||||
|
||||
public bool SetCreditorStatus(int creditorId, string status)
|
||||
@ -23,11 +23,11 @@ namespace COA.EnterpriseServices.Creditors
|
||||
return creditorHelper.SetCreditorStatus(creditorId, status);
|
||||
}
|
||||
|
||||
public void AddOfferResponse()
|
||||
public void AddOfferResponse(OfferResponse response)
|
||||
{
|
||||
// just a stub until we add actual DataObjects
|
||||
|
||||
creditorHelper.SetOriginalCreditorAsPrimary(1);
|
||||
creditorHelper.SetOriginalCreditorAsPrimary(response.CreditorId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,122 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using COA.EnterpriseServices.DataAccess.EntityFramework;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace COA.EnterpriseServices.DataAccess.EntityFramework.Migrations
|
||||
{
|
||||
[DbContext(typeof(QuickBaseContext))]
|
||||
[Migration("20201015133238_add-account-number")]
|
||||
partial class addaccountnumber
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "3.1.9")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128)
|
||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
||||
|
||||
modelBuilder.Entity("COA.EnterpriseServices.DataAccess.Entities.Client", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
||||
|
||||
b.Property<string>("Address")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("City")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<DateTime>("Created")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("FirstName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("LastName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<DateTime>("Modified")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<long>("Phone")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("State")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Zip")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Clients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("COA.EnterpriseServices.DataAccess.Entities.Creditor", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
||||
|
||||
b.Property<string>("AccountNumber")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("ClientFirstName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("ClientLastName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<DateTime>("Created")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("CurrentCreditorProfileId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("Modified")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("OriginalCreditorProfileId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Status")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Creditors");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("COA.EnterpriseServices.DataAccess.Entities.SettlementAttempt", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
||||
|
||||
b.Property<DateTime>("Created")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime>("Modified")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("SettlementAttempts");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace COA.EnterpriseServices.DataAccess.EntityFramework.Migrations
|
||||
{
|
||||
public partial class addaccountnumber : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "AccountNumber",
|
||||
table: "Creditors",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "AccountNumber",
|
||||
table: "Creditors");
|
||||
}
|
||||
}
|
||||
}
|
@ -68,6 +68,9 @@ namespace COA.EnterpriseServices.DataAccess.EntityFramework.Migrations
|
||||
.HasColumnType("int")
|
||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
|
||||
|
||||
b.Property<string>("AccountNumber")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("ClientFirstName")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
|
@ -14,6 +14,6 @@ namespace COA.EnterpriseServices.DataAccess.EntityFramework
|
||||
|
||||
public DbSet<Creditor> Creditors { get; set; }
|
||||
public DbSet<SettlementAttempt> SettlementAttempts { get; set; }
|
||||
public DbSet<Client> Clients { get; set; }
|
||||
public DbSet<Entities.Client> Clients { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,10 @@
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="COA.PartnerApis.QuickBase" Version="20.9.30.2-alpha" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\COA.EnterpriseServices.DataAccess\COA.EnterpriseServices.DataAccess.csproj" />
|
||||
</ItemGroup>
|
||||
|
@ -24,13 +24,13 @@ namespace COA.EnterpriseServices.DataAccess.QuickBase
|
||||
AddFieldMap<Creditor>(c => c.CurrentCreditorProfileId, 90);
|
||||
AddFieldMap<Creditor>(c => c.OriginalCreditorProfileId, 91);
|
||||
|
||||
AddFieldMap<Client>(c => c.Id, 1);
|
||||
AddFieldMap<Client>(c => c.Created, 2);
|
||||
AddFieldMap<Client>(c => c.Modified, 3);
|
||||
AddFieldMap<Client>(c => c.Email, 10);
|
||||
AddFieldMap<Client>(c => c.Phone, 11);
|
||||
AddFieldMap<Client>(c => c.FirstName, 20);
|
||||
AddFieldMap<Client>(c => c.LastName, 21);
|
||||
AddFieldMap<Entities.Client>(c => c.Id, 1);
|
||||
AddFieldMap<Entities.Client>(c => c.Created, 2);
|
||||
AddFieldMap<Entities.Client>(c => c.Modified, 3);
|
||||
AddFieldMap<Entities.Client>(c => c.Email, 10);
|
||||
AddFieldMap<Entities.Client>(c => c.Phone, 11);
|
||||
AddFieldMap<Entities.Client>(c => c.FirstName, 20);
|
||||
AddFieldMap<Entities.Client>(c => c.LastName, 21);
|
||||
}
|
||||
|
||||
internal static void AddFieldMap<TEntity>(Expression<Func<TEntity, object>> property, int fieldId)
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoMapper" Version="10.0.0" />
|
||||
<PackageReference Include="DataObjects" Version="20.10.2.3-alpha" />
|
||||
<PackageReference Include="StructureMap" Version="4.7.1" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using COA.EnterpriseServices.DataAccess.Helpers;
|
||||
using AutoMapper;
|
||||
using COA.EnterpriseServices.DataAccess.Helpers;
|
||||
using StructureMap;
|
||||
|
||||
namespace COA.EnterpriseServices.DataAccess
|
||||
@ -23,6 +24,8 @@ namespace COA.EnterpriseServices.DataAccess
|
||||
c.For(typeof(IDataAccess<>)).Singleton();
|
||||
c.For(typeof(DataAccessManager<>)).Singleton();
|
||||
|
||||
c.For<IMapper>().Singleton().Use(() => Mapping.GetMapper());
|
||||
|
||||
c.For<ClientHelper>().Singleton();
|
||||
c.For<CreditorHelper>().Singleton();
|
||||
});
|
||||
|
@ -12,5 +12,6 @@ namespace COA.EnterpriseServices.DataAccess.Entities
|
||||
public string ClientLastName { get; set; }
|
||||
public int CurrentCreditorProfileId { get; set; }
|
||||
public int OriginalCreditorProfileId { get; set; }
|
||||
public string AccountNumber { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +1,22 @@
|
||||
using COA.EnterpriseServices.DataAccess.Entities;
|
||||
using AutoMapper;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace COA.EnterpriseServices.DataAccess.Helpers
|
||||
{
|
||||
public class ClientHelper
|
||||
{
|
||||
private readonly DataAccessManager<Client> clientDataAccess;
|
||||
private readonly DataAccessManager<Entities.Client> clientDataAccess;
|
||||
|
||||
public ClientHelper(DataAccessManager<Client> clientDataAccess)
|
||||
public ClientHelper(DataAccessManager<Entities.Client> clientDataAccess, IMapper mapper)
|
||||
{
|
||||
this.clientDataAccess = clientDataAccess;
|
||||
}
|
||||
|
||||
public ICollection<Client> FindByEmail(string email)
|
||||
public ICollection<Entities.Client> FindByEmail(string email)
|
||||
{
|
||||
return clientDataAccess.Get(c => c.Email.Equals(email));
|
||||
var client = clientDataAccess.Get(c => c.Email.Equals(email));
|
||||
|
||||
return client;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
using COA.EnterpriseServices.DataAccess.Entities;
|
||||
using System.Collections.Generic;
|
||||
using AutoMapper;
|
||||
using COA.EnterpriseServices.DataAccess.Entities;
|
||||
|
||||
namespace COA.EnterpriseServices.DataAccess.Helpers
|
||||
{
|
||||
@ -7,16 +7,21 @@ namespace COA.EnterpriseServices.DataAccess.Helpers
|
||||
{
|
||||
private readonly DataAccessManager<Creditor> creditorDataAccess;
|
||||
private readonly DataAccessManager<SettlementAttempt> settlementAttemptDataAccess;
|
||||
private readonly IMapper mapper;
|
||||
|
||||
public CreditorHelper(DataAccessManager<Creditor> creditorDataAccess, DataAccessManager<SettlementAttempt> settlementAttemptDataAccess)
|
||||
public CreditorHelper(DataAccessManager<Creditor> creditorDataAccess, DataAccessManager<SettlementAttempt> settlementAttemptDataAccess, IMapper mapper)
|
||||
{
|
||||
this.creditorDataAccess = creditorDataAccess;
|
||||
this.settlementAttemptDataAccess = settlementAttemptDataAccess;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
public Creditor GetCreditor(int id)
|
||||
public Creditors.Creditor GetCreditor(int id)
|
||||
{
|
||||
return creditorDataAccess.Get(id);
|
||||
var creditor = creditorDataAccess.Get(id);
|
||||
|
||||
// map EF => domain type
|
||||
return mapper.Map<Creditors.Creditor>(creditor);
|
||||
}
|
||||
|
||||
public SettlementAttempt GetSettlementAttempt(int id)
|
||||
@ -24,32 +29,18 @@ namespace COA.EnterpriseServices.DataAccess.Helpers
|
||||
return settlementAttemptDataAccess.Get(id);
|
||||
}
|
||||
|
||||
public ICollection<Creditor> FindByName(string name)
|
||||
public bool AddCreditor(Creditors.Creditor creditor)
|
||||
{
|
||||
// TODO: use AutoMapper to return mapped domain objects!
|
||||
var creditorEntity = mapper.Map<Creditor>(creditor);
|
||||
|
||||
return creditorDataAccess.Get(c => c.ClientFirstName.Contains(name) || c.ClientLastName.Contains(name));
|
||||
}
|
||||
|
||||
public ICollection<Creditor> FindByStatus(string status)
|
||||
{
|
||||
// TODO: use AutoMapper to return mapped domain objects!
|
||||
|
||||
return creditorDataAccess.Get(c => c.Status == status);
|
||||
}
|
||||
|
||||
public bool AddCreditor(Creditor creditor)
|
||||
{
|
||||
// TODO: use AutoMapper to pass in mapped domain object!
|
||||
|
||||
return creditorDataAccess.Add(creditor);
|
||||
return creditorDataAccess.Add(creditorEntity);
|
||||
}
|
||||
|
||||
public bool UpdateCreditor(Creditor creditor)
|
||||
{
|
||||
// TODO: use AutoMapper to pass in mapped domain object!
|
||||
var creditorEntity = mapper.Map<Creditor>(creditor);
|
||||
|
||||
return creditorDataAccess.Update(creditor);
|
||||
return creditorDataAccess.Update(creditorEntity);
|
||||
}
|
||||
|
||||
public bool SetCreditorStatus(int creditorId, string status)
|
||||
|
20
COA.EnterpriseServices.DataAccess/Mapping.cs
Normal file
20
COA.EnterpriseServices.DataAccess/Mapping.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using AutoMapper;
|
||||
using AutoMapper.Configuration;
|
||||
|
||||
namespace COA.EnterpriseServices.DataAccess
|
||||
{
|
||||
public static class Mapping
|
||||
{
|
||||
public static IMapper GetMapper()
|
||||
{
|
||||
var cfg = new MapperConfigurationExpression();
|
||||
cfg.AddProfile<MappingProfile>();
|
||||
|
||||
//Mapper.Initialize(cfg);
|
||||
// or
|
||||
var mapperConfig = new MapperConfiguration(cfg);
|
||||
|
||||
return new Mapper(mapperConfig);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using AutoMapper;
|
||||
using COA.EnterpriseServices.Creditors;
|
||||
|
||||
namespace COA.EnterpriseServices.DataAccess
|
||||
{
|
||||
@ -6,7 +7,23 @@ namespace COA.EnterpriseServices.DataAccess
|
||||
{
|
||||
public MappingProfile()
|
||||
{
|
||||
// add mappings between domain and entity objects here
|
||||
#region EF => Domain
|
||||
|
||||
CreateMap<Entities.Creditor, Creditor>()
|
||||
.ForMember(d => d.creditorStatus, o => o.MapFrom(s => s.Status));
|
||||
|
||||
CreateMap<Entities.Client, Client.Client>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Domain => EF
|
||||
|
||||
CreateMap<Creditor, Entities.Creditor>()
|
||||
.ForMember(d => d.Status, o => o.MapFrom(s => s.creditorStatus));
|
||||
|
||||
CreateMap<Client.Client, Entities.Client>();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
using COA.EnterpriseServices.Creditors;
|
||||
using COA.EnterpriseServices.DataAccess;
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace COA.EnterpriseServices.Sandbox
|
||||
{
|
||||
@ -11,10 +10,13 @@ namespace COA.EnterpriseServices.Sandbox
|
||||
{
|
||||
var creditorController = Dependencies.Container.GetInstance<CreditorController>();
|
||||
|
||||
//Console.WriteLine(creditorController.GetCreditorStatus(1));
|
||||
Console.WriteLine(creditorController.GetCreditorStatus(1));
|
||||
//Console.WriteLine(creditorController.SetCreditorStatus(1, "Active"));
|
||||
|
||||
creditorController.AddOfferResponse();
|
||||
//creditorController.AddOfferResponse(new OfferResponse
|
||||
//{
|
||||
// CreditorId = 1
|
||||
//});
|
||||
|
||||
Console.ReadLine();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user