Skip to content

Commit

Permalink
Addrsn (#299)
Browse files Browse the repository at this point in the history
* first draft addrsn but

* ADD Rsn button code

* tidy up

* make prettier happy

* fix tests
pr feedback
  • Loading branch information
andrewfraser73 authored Nov 19, 2021
1 parent 678acb2 commit d4c77b9
Show file tree
Hide file tree
Showing 13 changed files with 332 additions and 14 deletions.
10 changes: 10 additions & 0 deletions src/Domain.LinnApps/ExportRsn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,15 @@ public class ExportRsn
public string CountryName { get; set; }

public string AccountType { get; set; }

public string InvoiceDescription { get; set; }

public int? Weight { get; set; }

public int? Height { get; set; }

public int? Depth { get; set; }

public int? Width { get; set; }
}
}
7 changes: 6 additions & 1 deletion src/Facade/ResourceBuilders/ExportRsnResourceBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ public ExportRsnResource Build(ExportRsn exportRsn)
OutletNumber = exportRsn.OutletNumber,
Country = exportRsn.Country,
CountryName = exportRsn.CountryName,
AccountType = exportRsn.AccountType
AccountType = exportRsn.AccountType,
InvoiceDescription = exportRsn.InvoiceDescription,
Depth = exportRsn.Depth,
Height = exportRsn.Height,
Weight = exportRsn.Weight,
Width = exportRsn.Width
};
}

Expand Down
19 changes: 16 additions & 3 deletions src/Facade/Services/ExportRsnService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace Linn.Stores.Facade.Services
{
using System.Collections.Generic;
using System.Linq;
using Linn.Common.Facade;
using Linn.Common.Persistence;
using Linn.Stores.Domain.LinnApps;
Expand All @@ -14,16 +15,28 @@ public ExportRsnService(IQueryRepository<ExportRsn> repository)
this.repository = repository;
}

public IResult<IEnumerable<ExportRsn>> SearchRsns(int accountId, int? outletNumber)
public IEnumerable<ExportRsn> FindMatchingRSNs(IEnumerable<ExportRsn> rsns, string searchTerm)
{
if (string.IsNullOrEmpty(searchTerm))
{
return rsns;
}

return rsns.ToList().Where(r => r.RsnNumber.ToString().Contains(searchTerm));
}

public IResult<IEnumerable<ExportRsn>> SearchRsns(int accountId, int? outletNumber, string searchTerm)
{
if (outletNumber != null)
{
return new SuccessResult<IEnumerable<ExportRsn>>(
this.repository.FilterBy(rsn => rsn.AccountId == accountId && rsn.OutletNumber == outletNumber));
this.FindMatchingRSNs(this.repository.FilterBy(rsn => rsn.AccountId == accountId && rsn.OutletNumber == outletNumber), searchTerm));
}

return new SuccessResult<IEnumerable<ExportRsn>>(
this.repository.FilterBy(rsn => rsn.AccountId == accountId));
this.FindMatchingRSNs(this.repository.FilterBy(rsn => rsn.AccountId == accountId),searchTerm));
}


}
}
2 changes: 1 addition & 1 deletion src/Facade/Services/IExportRsnService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

public interface IExportRsnService
{
IResult<IEnumerable<ExportRsn>> SearchRsns(int accountId, int? outletNumber);
IResult<IEnumerable<ExportRsn>> SearchRsns(int accountId, int? outletNumber, string searchTerm);
}
}
5 changes: 5 additions & 0 deletions src/Persistence.LinnApps/ServiceDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1381,6 +1381,11 @@ private void QueryExportRsns(ModelBuilder builder)
q.Property(e => e.Country).HasColumnName("COUNTRY").HasMaxLength(2);
q.Property(e => e.CountryName).HasColumnName("COUNTRY_NAME").HasMaxLength(50);
q.Property(e => e.AccountType).HasColumnName("ACCOUNT_TYPE").HasMaxLength(10);
q.Property(e => e.InvoiceDescription).HasColumnName("INVOICE_DESCRIPTION").HasMaxLength(50);
q.Property(e => e.Weight).HasColumnName("WEIGHT");
q.Property(e => e.Height).HasColumnName("HEIGHT");
q.Property(e => e.Depth).HasColumnName("DEPTH");
q.Property(e => e.Width).HasColumnName("WIDTH");
}

private void QuerySalesAccounts(ModelBuilder builder)
Expand Down
10 changes: 10 additions & 0 deletions src/Resources/ExportRsnResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,15 @@ public class ExportRsnResource
public string CountryName { get; set; }

public string AccountType { get; set; }

public string InvoiceDescription { get; set; }

public int? Weight { get; set; }

public int? Height { get; set; }

public int? Depth { get; set; }

public int? Width { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ public class ExportRsnSearchRequestResource
public int AccountId { get; set; }

public int? OutletNumber { get; set; }

public string SearchTerm { get; set; }
}
}
Loading

0 comments on commit d4c77b9

Please sign in to comment.