public ProductViewModel(Product product, IList<Category> categories) : this() { this.ProductId = product.Id; this.ProductGuid = product.Guid; this.Code = product.Code; this.Title = product.Title; this.Description = product.Description; this.Keywords = product.Keywords; this.Cost = product.Cost; this.Type = product.Type; this.IsFeatured = product.IsFeatured; this.ImageUrls = product.Images.Select(o => new ProductImageViewModel(o)).ToList(); foreach (Category category in categories.OrderBy(o => o.DisplayName)) { CategoryViewModel categoryViewModel = new CategoryViewModel(category); categoryViewModel.Selected = product.Categories.Any(o => o.Id == category.Id); foreach(var child in category.Children) { categoryViewModel.Children.First(o => o.Id == child.Id).Selected = product.Categories.Any(o => o.Id == category.Id && o.Children.Any(x => x.Id == child.Id)); } this.Categories.Add(categoryViewModel); } }
public ProductLinkViewModel(Product product, Category category, bool includeHostName) { this.Id = product.Id; this.Title = product.Title; this.Category = new CategoryViewModel(category); this.Type = product.Type; this.IncludeHostName = includeHostName; }
public ProductCartItem(Product product) { this.Id = product.Id; this.Title = product.Title; this.Description = product.Description; this.Cost = product.Cost; this.Images = product.Images; this.Categories = product.Categories; }
public ThemeProductViewModel(ThemeProduct themeProduct, Product product) { this.Guid = themeProduct.Guid; this.X = themeProduct.X; this.Y = themeProduct.Y; this.Qty = themeProduct.Qty; this.ProductGuid = themeProduct.ProductGuid; this.Product = new ProductViewModel(product, new List<Category>()); }
public AddProductToCartViewModel(Product product, int totalInventoryAvailable, bool inCart) { this.TotalInventoryAvailable = totalInventoryAvailable; this.InCart = inCart; this.ProductTitle = product.Title; this.InventoryCount = new List<SelectListItem>(); for(int i = 1; i <= totalInventoryAvailable; i++) { this.InventoryCount.Add(new SelectListItem() { Text = i.ToString(), Value = i.ToString() }); } }
public ProductViewModel(Product product) { this.Id = product.Id; this.Guid = product.Guid; this.Images = product.Images.Select(o => new ProductImageViewModel(o)).ToList(); this.Cost = product.Cost.ToString("C"); this.Title = product.Title; this.Description = product.Description; this.IsAvailable = product.Inventory > 0; this.Categories = product.Categories.Select(o => new CategoryViewModel(o)).ToList(); this.Type = product.Type; this.SeoKeywords = product.Keywords; this.IsCustomisableInvitation = ProductHelper.IsCustomisableInvitation(product); }
public ThemeProductViewModel(ThemeProduct themeProduct, Product product) { this.Guid = themeProduct.Guid; this.X = themeProduct.X; this.Y = themeProduct.Y; this.ProductGuid = themeProduct.ProductGuid; this.Cost = product.Cost.ToString("C"); this.Title = product.Title; this.ProductId = product.Id; this.Description = product.Description; this.Qty = themeProduct.Qty; this.SeoKeywords = product.Keywords; this.Images = product.Images.Select(o => new ProductImageViewModel(o)).ToList(); }
internal void AddProduct(int quantity, Product product) { if (this.Items.Any(o => o.Product.Guid == product.Guid)) { CartItem cartItem = this.Items.FirstOrDefault(o => o.Product.Guid == product.Guid); quantity += cartItem.Quantity; cartItem.ChangeQuantity(quantity); } else { this.Items.Add(new CartItem(quantity, product)); } }
public ProductListItemViewModel(Product product) { this.Id = product.Id; this.Guid = product.Guid; if (product.Images.Any()) { this.Image = new ProductImageViewModel(product.Images.First()); } this.Cost = product.Cost.ToString("C"); this.Title = product.Title; this.Description = product.Description; this.Type = product.Type; this.Categories = product.Categories.Select(o => new CategoryViewModel(o)).ToList(); this.IsCustomisableInvitation = ProductHelper.IsCustomisableInvitation(product); }
public ProductListItemViewModel(Product product) { this.Id = product.Id; if (product.Images.Any()) { this.Image = new ProductImageViewModel(product.Images.First()); } else { this.Image = new ProductImageViewModel(); } this.Cost = product.Cost.ToString("C"); this.Title = product.Title; this.Description = product.Description; }
public HireAddProductToCartViewModel(Product product, int totalInventoryAvailable, bool inCart, DateTime partyDate) { this.TotalInventoryAvailable = totalInventoryAvailable; this.InCart = inCart; this.ProductTitle = product.Title; this.ProductGuid = product.Guid; this.ProductId = product.Id; this.PartyDate = partyDate; this.InventoryCount = new List<SelectListItem>(); for(int i = 1; i <= totalInventoryAvailable; i++) { this.InventoryCount.Add(new SelectListItem() { Text = i.ToString(), Value = i.ToString() }); } }
public PostcodeCheckViewModel(Product product) { this.Product = new ProductViewModel(product); }
public CartItem(int quantity, Product product) : this() { this.Quantity = quantity; this.Product = product; }
public HireProductViewModel(Product product, HireDatesViewModel hireDates) : base(product) { this.PartyDate = hireDates.PartyDate; }
private Product ConvertToProduct(ProductDb productDb) { IList<Category> categories = this._serializer.Deserialize<List<Category>>(productDb.Categories); IList<IProductImage> images = this._serializer.Deserialize<List<IProductImage>>(productDb.Images); Product product = new Product() { Id = productDb.Id, Guid = productDb.Guid, Type = productDb.Type, Code = productDb.Code, Title = productDb.Title, Description = productDb.Description, Keywords = productDb.Keywords, Cost = productDb.Price, IsFeatured = productDb.IsFeatured, Inventory = productDb.Inventory, Categories = categories, Images = images, }; return product; }
private void SaveProductCategories(Product product) { using (SqlConnection connection = new SqlConnection(this._connectionString)) { connection.Execute("Delete From VintageRabbit.ProductCategories Where ProductId = @ProductId", new { ProductId = product.Id }); } string sql = null; foreach(var category in product.Categories) { sql += string.Format("Insert Into VintageRabbit.ProductCategories (CategoryId, ProductId) Values ({0}, {1});", category.Id, product.Id); foreach(var childCategory in category.Children) { sql += string.Format("Insert Into VintageRabbit.ProductCategories (CategoryId, ProductId) Values ({0}, {1});", childCategory.Id, product.Id); } } if (!string.IsNullOrEmpty(sql)) { using (SqlConnection connection = new SqlConnection(this._connectionString)) { connection.Execute(sql); } } }
public Product SaveProduct(Product product, IActionBy actionBy) { string categories = this._serializer.Serialize(product.Categories); string images = this._serializer.Serialize(product.Images); if (product.Id == 0) { string sql = @"Insert Into VintageRabbit.Products ([Guid], Code, [Type], Title, Description, Price, Keywords, Inventory, IsFeatured, DateCreated, DateLastModified, UpdatedBy, Categories, Images) Values (@Guid, @Code, @Type, @Title, @Description, @Price, @Keywords, @Inventory, @IsFeatured, @DateCreated, @DateLastModified, @UpdatedBy, @Categories, @Images); Select cast(SCOPE_IDENTITY() as int)"; using (SqlConnection connection = new SqlConnection(this._connectionString)) { IEnumerable<int> productIds = connection.Query<int>(sql, new { Guid = product.Guid, Code = product.Code, Type = product.Type.ToString(), Title = product.Title, Description = product.Description, Price = product.Cost, Keywords = product.Keywords, IsFeatured = product.IsFeatured, DateCreated = DateTime.Now, DateLastModified = DateTime.Now, UpdatedBy = actionBy.Email, Categories = categories, Inventory = product.Inventory, Images = images }); if(productIds.Any()) { product.Id = productIds.First(); } } } else { string sql = @"Update VintageRabbit.Products Set [Guid] = @Guid, Code = @Code, [Type] = @Type, Title = @Title, Description = @Description, Price = @Price, Keywords = @Keywords, IsFeatured = @IsFeatured, Inventory = @Inventory, DateLastModified = @DateLastModified, UpdatedBy = @UpdatedBy, Categories = @Categories, Images = @Images Where Id = @ProductId"; using (SqlConnection connection = new SqlConnection(this._connectionString)) { connection.Execute(sql, new { Guid = product.Guid, Code = product.Code, Type = product.Type.ToString(), Title = product.Title.Trim(), Description = product.Description.Trim(), Price = product.Cost, Keywords = product.Keywords, IsFeatured = product.IsFeatured, DateLastModified = DateTime.Now, UpdatedBy = actionBy.Email, Categories = categories, Inventory = product.Inventory, Images = images, ProductId = product.Id }); } } this.SaveProductCategories(product); return product; }
public ProductAddedToCart(Cart cart, Product product) { this.Cart = cart; this.Product = product; }
public InventoryPageViewModel(Product product, IList<InventoryItem> inventory) { this.Product = new ProductViewModel(product, new List<Category>()); this.Inventory = inventory.Select(o => new InventoryItemViewModel(o)).ToList(); this.AddInventory = new AddInventoryViewModel(); }
public BuyProductCartItem(Product product) : base(product) { }
public SaveProductMessage(Product product, IActionBy actionBy) { this.Product = product; this.ActionBy = actionBy; }