public ProductParameterValueRepositoryTests() { var contaxt = new DataLayer.InventoryDBContext(); var relateduser = contaxt.Users.FirstOrDefault(u => u.Username.Equals("admin")); var identity = new GenericIdentity(relateduser.Username); var roles = relateduser.Roles.Select(p => p.Title).ToArray(); var principal = new GenericPrincipal(identity, roles); System.Threading.Thread.CurrentPrincipal = principal; _ProductParameterValue = new Repositories.ProductParameterValueRepository(); EProductParameterValue = new Entities.ProductParameterValue() { ProductId = 1, ProductParameterId = 1, Value = "Value", }; }
public void AddParameter(int ProductCategoryId) { if (Entity.ProductCategoryId > 0) { var param = paramsRepo.GetAll(Entity.ProductCategoryId); var value = Pvalue.GetAll(Entity.ProductId); foreach (var item in param) { var txt = TextBox(item.Title, "param"); Entities.ProductParameterValue data = value.FirstOrDefault(p => p.ProductParameterId == item.ProductParameterId & p.ProductId == Entity.ProductId); if (data != default(Entities.ProductParameterValue)) { txt.Text = data.Value; } parameterControls.Add(item, txt); } } }