using System; using System.Collections.Generic; using System.Text; using System.IO; namespace App.Core { [EncapsulatesProperty("Name")] [EncapsulatesProperty("Price")] [EncapsulatesProperty("Photography")] public class ProductEditViewPresentationModel : EntityViewPresentationModel<Product> { protected void ChoosePhoto() { FileInfo info = ChooseImage("Choose a photo for the product"); if (info != null) { byte[] data; using (FileStream fs = info.OpenRead()) { data = new byte[fs.Length]; fs.Read(data, 0, data.Length); } SetPropertyValue("ProductPhotography", data); } } public override string DisplayName { get { if (_entity == null) return "Error - Invalid item"; if (_entity.Name == null || _entity.Name.Trim() == string.Empty) return "New Product"; return string.Format("Editing product '{0}'", _entity.Name); } set { base.DisplayName = value; } } } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)