public static SalesViewModel ExecuteCreate(ETC.Product product) { SalesViewModel result = null; if (product != null) { result = new SalesViewModel(product); } return(result); }
private SalesViewModel(ETC.Product product) { this.id = product.ID; this.name = product.Name; this.description = product.Description; this.price = product.Price; this.imageName = product.ImageName; this.imageSrc = PathUtility.CombineUrls(Config.StorageUrlProduct, product.ID.ToString(), product.ImageName); this.category = product.ExecuteCreateCategoryByCategoryID().Name; this.categoryID = product.CategoryID; this.status = (product.Status == ETC.Product.STATUS_ACTIVE) ? true : false; this.sellings = CountSells(product); }
private ProductViewModel(ETC.Product product) { this.id = product.ID; this.name = product.Name; this.description = product.Description; this.price = product.Price; this.imageName = product.ImageName; this.status = (product.Status == ETC.Product.STATUS_ACTIVE) ? true : false; this.categoryID = product.CategoryID; this.entity = product; this.category = product.ExecuteCreateCategoryByCategoryID(); this.categoryList = Lists.ListCategories(ETC.Category.ListByStatus(ETC.Category.STATUS_ACTIVE), Lists.SelectorType.WithSelect, null); this.isEditMode = true; }
public ShopViewModel(ETC.Product product) { if (product != null) { this.id = product.ID; this.name = product.Name; this.description = product.Description; this.price = product.Price; this.imageSrc = PathUtility.CombineUrls(Config.StorageUrlProduct, product.ID.ToString(), product.ImageName); this.category = product.ExecuteCreateCategoryByCategoryID().Name; this.categoryID = product.CategoryID; this.status = (product.Status == ETC.Product.STATUS_ACTIVE) ? true : false; this.quantity = 1; } }
private int CountSells(ETC.Product product) { List <ETC.OrderItem> orderItemList = ETC.OrderItem.ListByProductID(product.ID); int sellings = 0; foreach (ETC.OrderItem item in orderItemList) { if (item.ExecuteCreateOrderByOrderID().Status == ETC.Order.STATUS_COMPLETED) { sellings += item.Quantity; } } return(sellings); }
public void Save() { if (this.id != Constants.DEFAULT_VALUE_INT) { ETC.Product product = this.entity ?? ETC.Product.ExecuteCreate(this.id); if (product != null) { if (this.image != null) { SaveImg(); } product.Update( this.categoryID, this.name, this.description, this.price, this.imageName, this.status ? ETC.Product.STATUS_ACTIVE : ETC.Product.STATUS_INACTIVE, Common.Session.Account.ID); } } else { ETC.Product product = ETC.Product.ExecuteCreate( this.categoryID, this.name, this.description, this.price, this.imageName, this.status ? ETC.Product.STATUS_ACTIVE : ETC.Product.STATUS_INACTIVE, Common.Session.Account.ID, Common.Session.Account.ID); product.Insert(); this.id = product.ID; if (this.image != null) { SaveImg(); } } if (!String.IsNullOrEmpty(this.TempFolderPath) && Directory.Exists(this.TempFolderPath)) { Directory.Delete(this.TempFolderPath, true); } }
private SalesViewModel SearchProduct(int?selectedProduct) { SalesViewModel result = null; if (selectedProduct.HasValue) { ETC.Product product = ETC.Product.ExecuteCreate(selectedProduct.Value); if (product != null) { result = SalesViewModel.ExecuteCreate(product); } } return(result); }
public static ProductViewModel ExecuteCreate(int?id) { ProductViewModel result = null; if (id.HasValue) { ETC.Product entity = ETC.Product.ExecuteCreate(id.Value); if (entity != null) { result = new ProductViewModel(entity); } } else { result = new ProductViewModel(); } return(result); }