|
|
|
|
@ -1821,19 +1821,8 @@ namespace Gremlin.GremlinData.DBClasses
|
|
|
|
|
|
|
|
|
|
public static Account ResolveAccountByName(GremlinContext context, string AccName)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Account query = context.Accounts
|
|
|
|
|
.Include(a => a.AccountType)
|
|
|
|
|
.Include(a => a.SubMarket)
|
|
|
|
|
.Where(a => a.AccountName == AccName)
|
|
|
|
|
.First();
|
|
|
|
|
return query;
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
try { return context.Accounts.Include(a => a.AccountType).Include(a => a.SubMarket).Where(a => a.AccountName == AccName).First(); }
|
|
|
|
|
catch { return null; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static Account ResolveAccountById(GremlinContext context, uint accountId)
|
|
|
|
|
@ -1850,79 +1839,32 @@ namespace Gremlin.GremlinData.DBClasses
|
|
|
|
|
|
|
|
|
|
public static AccountType ResolveAccountType(GremlinContext context, string AccTypeCode)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
AccountType accountType = context.AccountTypes
|
|
|
|
|
.Where(account => account.AccountTypeCode == AccTypeCode)
|
|
|
|
|
.First();
|
|
|
|
|
return accountType;
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
try { return context.AccountTypes.Where(account => account.AccountTypeCode == AccTypeCode).First(); }
|
|
|
|
|
catch { return null; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static SubMarket ResolveSubmarket(GremlinContext context, string subMarketCode)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
SubMarket query = context.SubMarkets
|
|
|
|
|
.Where(a => a.SubMarketCode == subMarketCode)
|
|
|
|
|
.First();
|
|
|
|
|
return query;
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
try { return context.SubMarkets.Where(a => a.SubMarketCode == subMarketCode).First(); }
|
|
|
|
|
catch { return null; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static Product GetProduct(GremlinContext context, string pn, string option)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Product query = context.Products
|
|
|
|
|
.Include(p => p.ProductLine)
|
|
|
|
|
.Include(p => p.CustomDescription)
|
|
|
|
|
.Where(a => a.ProductNumber == pn && a.OptionNumber == option)
|
|
|
|
|
.First();
|
|
|
|
|
return query;
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
try { return context.Products.Include(p => p.ProductLine).Include(p => p.CustomDescription).Where(a => a.ProductNumber == pn && a.OptionNumber == option).First(); }
|
|
|
|
|
catch { return null; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static Product ResolveProduct(GremlinContext context, string pn, string option)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Product query = context.Products
|
|
|
|
|
.Where(a => a.ProductNumber == pn && a.OptionNumber == option)
|
|
|
|
|
.First();
|
|
|
|
|
return query;
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
try {return context.Products.Where(a => a.ProductNumber == pn && a.OptionNumber == option).First(); }
|
|
|
|
|
catch { return null; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static ProductLine ResolveProductLine(GremlinContext context, string plCode)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
ProductLine query = context.ProductLines
|
|
|
|
|
.Where(a => a.ProductLineCode == plCode)
|
|
|
|
|
.First();
|
|
|
|
|
return query;
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
try { return context.ProductLines.Where(a => a.ProductLineCode == plCode).First(); }
|
|
|
|
|
catch { return null; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static readonly Random random = new();
|
|
|
|
|
@ -1935,14 +1877,14 @@ namespace Gremlin.GremlinData.DBClasses
|
|
|
|
|
|
|
|
|
|
public class ProductEqualityComparer : IEqualityComparer<Product>
|
|
|
|
|
{
|
|
|
|
|
public bool Equals(Product product1, Product product2)
|
|
|
|
|
public bool Equals(Product x, Product y)
|
|
|
|
|
{
|
|
|
|
|
return !((product1 != null || product2 != null)
|
|
|
|
|
&& !(product1 != null && product2 != null
|
|
|
|
|
&& product1.ProductNumber == product2.ProductNumber
|
|
|
|
|
&& product1.OptionNumber == product2.OptionNumber
|
|
|
|
|
&& product1.BreakRangeFrom == product2.BreakRangeFrom
|
|
|
|
|
&& product1.BreakRangeTo == product2.BreakRangeTo));
|
|
|
|
|
return !((x != null || y != null)
|
|
|
|
|
&& !(x != null && y != null
|
|
|
|
|
&& x.ProductNumber == y.ProductNumber
|
|
|
|
|
&& x.OptionNumber == y.OptionNumber
|
|
|
|
|
&& x.BreakRangeFrom == y.BreakRangeFrom
|
|
|
|
|
&& x.BreakRangeTo == y.BreakRangeTo));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int GetHashCode(Product product)
|
|
|
|
|
|