/// <summary> /// Retrieves a template from the db /// </summary> /// <returns></returns> public ItemObject RetrieveTemplate(string templateId) { ItemObject template = new ItemObject(2); using (OdinContext context = this.contextFactory.CreateContext()) { if (context.OdinItemTemplates.Any(o => o.TemplateId == templateId)) { OdinItemTemplates x = (from o in context.OdinItemTemplates where o.TemplateId == templateId select o).FirstOrDefault(); template.TemplateId = x.TemplateId; template.AccountingGroup = (!string.IsNullOrEmpty(x.AccountingGroup)) ? x.AccountingGroup : ""; template.CasepackHeight = (!string.IsNullOrEmpty(x.CasepackHeight)) ? x.CasepackHeight : ""; template.CasepackLength = (!string.IsNullOrEmpty(x.CasepackLength)) ? x.CasepackLength : ""; template.CasepackQty = (!string.IsNullOrEmpty(x.CasepackQty)) ? x.CasepackQty : ""; template.CasepackWidth = (!string.IsNullOrEmpty(x.CasepackWidth)) ? x.CasepackWidth : ""; template.CasepackWeight = (!string.IsNullOrEmpty(x.CasepackWeight)) ? x.CasepackWeight : ""; template.Category = (!string.IsNullOrEmpty(x.Category)) ? x.Category : ""; template.Category2 = (!string.IsNullOrEmpty(x.Category2)) ? x.Category2 : ""; template.Category3 = (!string.IsNullOrEmpty(x.Category3)) ? x.Category3 : ""; template.Copyright = (!string.IsNullOrEmpty(x.Copyright)) ? x.Copyright : ""; template.CostProfileGroup = (!string.IsNullOrEmpty(x.CostProfileGroup)) ? x.CostProfileGroup : ""; template.DefaultActualCostCad = (!string.IsNullOrEmpty(x.DefaultActualCostCad)) ? x.DefaultActualCostCad : ""; template.DefaultActualCostUsd = (!string.IsNullOrEmpty(x.DefaultActualCostUsd)) ? x.DefaultActualCostUsd : ""; template.DtcPrice = (!string.IsNullOrEmpty(x.DtcPrice)) ? x.DtcPrice : ""; template.Duty = (!string.IsNullOrEmpty(x.Duty)) ? x.Duty : ""; template.Gpc = (!string.IsNullOrEmpty(x.Gpc)) ? x.Gpc : ""; template.Height = (!string.IsNullOrEmpty(x.Height)) ? x.Height : ""; template.InnerpackHeight = (!string.IsNullOrEmpty(x.InnerpackHeight)) ? x.InnerpackHeight : ""; template.InnerpackLength = (!string.IsNullOrEmpty(x.InnerpackLength)) ? x.InnerpackLength : ""; template.InnerpackQuantity = (!string.IsNullOrEmpty(x.InnerpackQty)) ? x.InnerpackQty : ""; template.InnerpackWeight = (!string.IsNullOrEmpty(x.InnerpackWeight)) ? x.InnerpackWeight : ""; template.InnerpackWidth = (!string.IsNullOrEmpty(x.InnerpackWidth)) ? x.InnerpackWidth : ""; template.ItemCategory = (!string.IsNullOrEmpty(x.ItemCategory)) ? x.ItemCategory : ""; template.ItemFamily = (!string.IsNullOrEmpty(x.ItemFamily)) ? x.ItemFamily : ""; template.ItemGroup = (!string.IsNullOrEmpty(x.ItemGroup)) ? x.ItemGroup : ""; template.Length = (!string.IsNullOrEmpty(x.Length)) ? x.Length : ""; template.ListPriceCad = (!string.IsNullOrEmpty(x.ListPriceCad)) ? x.ListPriceCad : ""; template.ListPriceMxn = (!string.IsNullOrEmpty(x.ListPriceMxn)) ? x.ListPriceMxn : ""; template.ListPriceUsd = (!string.IsNullOrEmpty(x.ListPriceUsd)) ? x.ListPriceUsd : ""; template.MetaDescription = (!string.IsNullOrEmpty(x.MetaDescription)) ? x.MetaDescription : ""; template.MfgSource = (!string.IsNullOrEmpty(x.MfgSource)) ? x.MfgSource : ""; template.Msrp = (!string.IsNullOrEmpty(x.Msrp)) ? x.Msrp : ""; template.MsrpCad = (!string.IsNullOrEmpty(x.MsrpCad)) ? x.MsrpCad : ""; template.MsrpMxn = (!string.IsNullOrEmpty(x.MsrpMxn)) ? x.MsrpMxn : ""; template.PrintOnDemand = (!string.IsNullOrEmpty(x.PrintOnDemand)) ? x.PrintOnDemand : ""; template.ProductGroup = (!string.IsNullOrEmpty(x.ProductGroup)) ? x.ProductGroup : ""; template.ProductLine = (!string.IsNullOrEmpty(x.ProductLine)) ? x.ProductLine : ""; template.ProductFormat = (!string.IsNullOrEmpty(x.ProductFormat)) ? x.ProductFormat : ""; template.ProductQty = (!string.IsNullOrEmpty(x.ProdQty)) ? x.ProdQty : ""; template.PricingGroup = (!string.IsNullOrEmpty(x.PricingGroup)) ? x.PricingGroup : ""; template.PsStatus = (!string.IsNullOrEmpty(x.PsStatus)) ? x.PsStatus : ""; template.SatCode = (!string.IsNullOrEmpty(x.SatCode)) ? x.SatCode : ""; template.Size = (!string.IsNullOrEmpty(x.Size)) ? x.Size : ""; template.TariffCode = (!string.IsNullOrEmpty(x.TariffCode)) ? x.TariffCode : ""; template.Udex = (!string.IsNullOrEmpty(x.Udex)) ? x.Udex : ""; template.WebsitePrice = (!string.IsNullOrEmpty(x.WebsitePrice)) ? x.WebsitePrice : ""; template.Weight = (!string.IsNullOrEmpty(x.Weight)) ? x.Weight : ""; template.Width = (!string.IsNullOrEmpty(x.Width)) ? x.Width : ""; template.EcommerceBullet1 = (!string.IsNullOrEmpty(x.EcommerceBullet1)) ? x.EcommerceBullet1 : ""; template.EcommerceBullet2 = (!string.IsNullOrEmpty(x.EcommerceBullet2)) ? x.EcommerceBullet2 : ""; template.EcommerceBullet3 = (!string.IsNullOrEmpty(x.EcommerceBullet3)) ? x.EcommerceBullet3 : ""; template.EcommerceBullet4 = (!string.IsNullOrEmpty(x.EcommerceBullet4)) ? x.EcommerceBullet4 : ""; template.EcommerceBullet5 = (!string.IsNullOrEmpty(x.EcommerceBullet5)) ? x.EcommerceBullet5 : ""; template.EcommerceComponents = (!string.IsNullOrEmpty(x.EcommerceComponents)) ? x.EcommerceComponents : ""; template.EcommerceCost = (!string.IsNullOrEmpty(x.EcommerceCost)) ? x.EcommerceCost : ""; template.EcommerceExternalIdType = (!string.IsNullOrEmpty(x.EcommerceExternalIdType)) ? x.EcommerceExternalIdType : ""; template.EcommerceItemHeight = (!string.IsNullOrEmpty(x.EcommerceItemHeight)) ? x.EcommerceItemHeight : ""; template.EcommerceItemTypeKeywords = (!string.IsNullOrEmpty(x.EcommerceItemTypeKeywords)) ? x.EcommerceItemTypeKeywords : ""; template.EcommerceItemLength = (!string.IsNullOrEmpty(x.EcommerceItemLength)) ? x.EcommerceItemLength : ""; template.EcommerceItemWeight = (!string.IsNullOrEmpty(x.EcommerceItemWeight)) ? x.EcommerceItemWeight : ""; template.EcommerceItemWidth = (!string.IsNullOrEmpty(x.EcommerceItemWidth)) ? x.EcommerceItemWidth : ""; template.EcommerceModelName = (!string.IsNullOrEmpty(x.EcommerceModelName)) ? x.EcommerceModelName : ""; template.EcommercePackageLength = (!string.IsNullOrEmpty(x.EcommercePackageLength)) ? x.EcommercePackageLength : ""; template.EcommercePackageHeight = (!string.IsNullOrEmpty(x.EcommercePackageHeight)) ? x.EcommercePackageHeight : ""; template.EcommercePackageWeight = (!string.IsNullOrEmpty(x.EcommercePackageWeight)) ? x.EcommercePackageWeight : ""; template.EcommercePackageWidth = (!string.IsNullOrEmpty(x.EcommercePackageWidth)) ? x.EcommercePackageWidth : ""; template.EcommercePageQty = (!string.IsNullOrEmpty(x.EcommercePageCount)) ? x.EcommercePageCount : ""; template.EcommerceProductCategory = (!string.IsNullOrEmpty(x.EcommerceProductCategory)) ? x.EcommerceProductCategory : ""; template.EcommerceProductDescription = (!string.IsNullOrEmpty(x.EcommerceProductDescription)) ? x.EcommerceProductDescription : ""; template.EcommerceProductSubcategory = (!string.IsNullOrEmpty(x.EcommerceProductSubcategory)) ? x.EcommerceProductSubcategory : ""; template.EcommerceManufacturerName = (!string.IsNullOrEmpty(x.EcommerceManufacturerName)) ? x.EcommerceManufacturerName : ""; template.EcommerceMsrp = (!string.IsNullOrEmpty(x.EcommerceMsrp)) ? x.EcommerceMsrp : ""; template.EcommerceSize = (!string.IsNullOrEmpty(x.EcommerceSize)) ? x.EcommerceSize : ""; template.Warranty = (!string.IsNullOrEmpty(x.Warranty)) ? x.Warranty : ""; } else { MessageBox.Show("Odin could not retrieve the selected template."); } } return(template); }
public void TemplateRepositoryTests_InsertTemplate_ShouldInsert() { #region Assemble DbHelpers.ClearDatabase(); TemplateRepository templateRepository = new TemplateRepository(DbHelpers.GetContextFactory()); ConnectionManager connectionManager = new ConnectionManager(@"(local)\SQLExpress", "Odin"); connectionManager.SetUseTrustedConnection(true); LogServiceFactory logServiceFactory = new LogServiceFactory("Odin"); OdinContextFactory OdinContextFactory = new OdinContextFactory(connectionManager, logServiceFactory); ItemObject template = new ItemObject(2); template.TemplateId = "TempalteId"; template.AccountingGroup = "AG"; template.CasepackHeight = "1"; template.CasepackLength = "2"; template.CasepackQty = "3"; template.CasepackWidth = "4"; template.CasepackWeight = "5"; template.Category = "c1"; template.Category2 = "c2"; template.Category3 = "c3"; template.Copyright = "copyright"; template.CostProfileGroup = "cpg"; template.DefaultActualCostUsd = "2"; template.DefaultActualCostCad = "5"; template.Duty = "4"; template.Gpc = "GPC"; template.Height = "99"; template.InnerpackHeight = "12"; template.InnerpackLength = "43"; template.InnerpackQuantity = "36"; template.InnerpackWidth = "12"; template.InnerpackWeight = "90"; template.ItemCategory = "IC"; template.ItemFamily = "IF"; template.ItemGroup = "IG"; template.Length = "4"; template.ListPriceCad = "4.22"; template.ListPriceUsd = "5.14"; template.ListPriceMxn = "8.45"; template.MetaDescription = "MD"; template.MfgSource = "MS"; template.Msrp = "9.09"; template.MsrpCad = "6.87"; template.MsrpMxn = "3.96"; template.PrintOnDemand = "P"; template.ProductFormat = "PF"; template.ProductGroup = "PG"; template.ProductLine = "PL"; template.ProductQty = "PQ"; template.PricingGroup = "PG"; template.PsStatus = "P"; template.SatCode = "SC"; template.Size = "Size"; template.TariffCode = "TC"; template.Udex = "Udex"; template.Weight = "23"; template.Width = "85"; template.EcommerceBullet1 = "EB1"; template.EcommerceBullet2 = "EB2"; template.EcommerceBullet3 = "EB3"; template.EcommerceBullet4 = "EB4"; template.EcommerceBullet5 = "EB5"; template.EcommerceComponents = "COM"; template.EcommerceCost = "66"; template.EcommerceExternalIdType = "EIT"; template.EcommerceItemHeight = "3"; template.EcommerceItemLength = "4"; template.EcommerceItemWeight = "5"; template.EcommerceItemWidth = "8"; template.EcommerceModelName = "MNAME"; template.EcommercePackageLength = "39"; template.EcommercePackageHeight = "65"; template.EcommercePackageWeight = "34"; template.EcommercePackageWidth = "82"; template.EcommercePageQty = "19"; template.EcommerceProductCategory = "PC"; template.EcommerceProductDescription = "PD"; template.EcommerceProductSubcategory = "PS"; template.EcommerceManufacturerName = "MANNAME"; template.EcommerceMsrp = "4.34"; template.EcommerceSize = "ESIZE"; #endregion // Assemble #region Act templateRepository.InsertTemplate(template); #endregion // Act #region Assert using (OdinContext context = OdinContextFactory.CreateContext()) { OdinItemTemplates odinItemTemplates = (from o in context.OdinItemTemplates select o).FirstOrDefault(); Assert.AreEqual(odinItemTemplates.TemplateId, "TempalteId"); Assert.AreEqual(odinItemTemplates.AccountingGroup, "AG"); Assert.AreEqual(odinItemTemplates.CasepackHeight, "1"); Assert.AreEqual(odinItemTemplates.CasepackLength, "2"); Assert.AreEqual(odinItemTemplates.CasepackQty, "3"); Assert.AreEqual(odinItemTemplates.CasepackWidth, "4"); Assert.AreEqual(odinItemTemplates.CasepackWeight, "5"); Assert.AreEqual(odinItemTemplates.Category, "c1"); Assert.AreEqual(odinItemTemplates.Category2, "c2"); Assert.AreEqual(odinItemTemplates.Category3, "c3"); Assert.AreEqual(odinItemTemplates.Copyright, "copyright"); Assert.AreEqual(odinItemTemplates.CostProfileGroup, "cpg"); Assert.AreEqual(odinItemTemplates.DefaultActualCostUsd, "2"); Assert.AreEqual(odinItemTemplates.DefaultActualCostCad, "5"); Assert.AreEqual(odinItemTemplates.Duty, "4"); Assert.AreEqual(odinItemTemplates.Gpc, "GPC"); Assert.AreEqual(odinItemTemplates.Height, "99"); Assert.AreEqual(odinItemTemplates.InnerpackHeight, "12"); Assert.AreEqual(odinItemTemplates.InnerpackLength, "43"); Assert.AreEqual(odinItemTemplates.InnerpackQty, "36"); Assert.AreEqual(odinItemTemplates.InnerpackWidth, "12"); Assert.AreEqual(odinItemTemplates.InnerpackWeight, "90"); Assert.AreEqual(odinItemTemplates.ItemCategory, "IC"); Assert.AreEqual(odinItemTemplates.ItemFamily, "IF"); Assert.AreEqual(odinItemTemplates.ItemGroup, "IG"); Assert.AreEqual(odinItemTemplates.Length, "4"); Assert.AreEqual(odinItemTemplates.ListPriceCad, "4.22"); Assert.AreEqual(odinItemTemplates.ListPriceUsd, "5.14"); Assert.AreEqual(odinItemTemplates.ListPriceMxn, "8.45"); Assert.AreEqual(odinItemTemplates.MetaDescription, "MD"); Assert.AreEqual(odinItemTemplates.MfgSource, "MS"); Assert.AreEqual(odinItemTemplates.Msrp, "9.09"); Assert.AreEqual(odinItemTemplates.MsrpCad, "6.87"); Assert.AreEqual(odinItemTemplates.MsrpMxn, "3.96"); Assert.AreEqual(odinItemTemplates.PrintOnDemand, "P"); Assert.AreEqual(odinItemTemplates.ProductFormat, "PF"); Assert.AreEqual(odinItemTemplates.ProductGroup, "PG"); Assert.AreEqual(odinItemTemplates.ProductLine, "PL"); Assert.AreEqual(odinItemTemplates.ProdQty, "PQ"); Assert.AreEqual(odinItemTemplates.PricingGroup, "PG"); Assert.AreEqual(odinItemTemplates.PsStatus, "P"); Assert.AreEqual(odinItemTemplates.SatCode, "SC"); Assert.AreEqual(odinItemTemplates.Size, "Size"); Assert.AreEqual(odinItemTemplates.TariffCode, "TC"); Assert.AreEqual(odinItemTemplates.Udex, "Udex"); Assert.AreEqual(odinItemTemplates.Weight, "23"); Assert.AreEqual(odinItemTemplates.Width, "85"); Assert.AreEqual(odinItemTemplates.EcommerceBullet1, "EB1"); Assert.AreEqual(odinItemTemplates.EcommerceBullet2, "EB2"); Assert.AreEqual(odinItemTemplates.EcommerceBullet3, "EB3"); Assert.AreEqual(odinItemTemplates.EcommerceBullet4, "EB4"); Assert.AreEqual(odinItemTemplates.EcommerceBullet5, "EB5"); Assert.AreEqual(odinItemTemplates.EcommerceComponents, "COM"); Assert.AreEqual(odinItemTemplates.EcommerceCost, "66"); Assert.AreEqual(odinItemTemplates.EcommerceExternalIdType, "EIT"); Assert.AreEqual(odinItemTemplates.EcommerceItemHeight, "3"); Assert.AreEqual(odinItemTemplates.EcommerceItemLength, "4"); Assert.AreEqual(odinItemTemplates.EcommerceItemWeight, "5"); Assert.AreEqual(odinItemTemplates.EcommerceItemWidth, "8"); Assert.AreEqual(odinItemTemplates.EcommerceModelName, "MNAME"); Assert.AreEqual(odinItemTemplates.EcommercePackageLength, "39"); Assert.AreEqual(odinItemTemplates.EcommercePackageHeight, "65"); Assert.AreEqual(odinItemTemplates.EcommercePackageWeight, "34"); Assert.AreEqual(odinItemTemplates.EcommercePackageWidth, "82"); Assert.AreEqual(odinItemTemplates.EcommercePageCount, "19"); Assert.AreEqual(odinItemTemplates.EcommerceProductCategory, "PC"); Assert.AreEqual(odinItemTemplates.EcommerceProductDescription, "PD"); Assert.AreEqual(odinItemTemplates.EcommerceProductSubcategory, "PS"); Assert.AreEqual(odinItemTemplates.EcommerceManufacturerName, "MANNAME"); Assert.AreEqual(odinItemTemplates.EcommerceMsrp, "4.34"); Assert.AreEqual(odinItemTemplates.EcommerceSize, "ESIZE"); } #endregion // Assert }