Exemple #1
0
        private CategoryViewModel(ETC.Category category)
        {
            this.id          = category.ID;
            this.name        = category.Name;
            this.description = category.Description;
            this.imageName   = category.ImageName;
            this.status      = (category.Status == ETC.Category.STATUS_ACTIVE) ? true : false;
            this.entity      = category;

            this.IsEditMode = true;
        }
Exemple #2
0
        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;
        }
Exemple #3
0
        public void Save()
        {
            if (this.id != Constants.DEFAULT_VALUE_INT)
            {
                ETC.Category category = this.entity ?? ETC.Category.ExecuteCreate(this.id);

                if (category != null)
                {
                    if (this.image != null)
                    {
                        SaveImg();
                    }

                    category.Update(
                        this.name,
                        this.description,
                        this.imageName,
                        this.status ? ETC.Category.STATUS_ACTIVE : ETC.Category.STATUS_INACTIVE,
                        Common.Session.Account.ID);
                }
            }
            else
            {
                ETC.Category category = ETC.Category.ExecuteCreate(
                    this.name,
                    this.description,
                    this.imageName,
                    this.status ? ETC.Category.STATUS_ACTIVE : ETC.Category.STATUS_INACTIVE,
                    Common.Session.Account.ID,
                    Common.Session.Account.ID);
                category.Insert();
                this.id = category.ID;

                if (this.image != null)
                {
                    SaveImg();
                }
            }

            if (!String.IsNullOrEmpty(this.TempFolderPath) && Directory.Exists(this.TempFolderPath))
            {
                Directory.Delete(this.TempFolderPath, true);
            }
        }
Exemple #4
0
        public static CategoryViewModel ExecuteCreate(int?id)
        {
            CategoryViewModel result = null;

            if (id.HasValue)
            {
                ETC.Category entity = ETC.Category.ExecuteCreate(id.Value);

                if (entity != null)
                {
                    result = new CategoryViewModel(entity);
                }
            }
            else
            {
                result = new CategoryViewModel();
            }

            return(result);
        }
        public static ReportViewModel ExecuteCreate(int?TopSellingFilterBy, int?SelectedProduct)
        {
            ReportViewModel result = new ReportViewModel(TopSellingFilterBy, SelectedProduct);

            if (TopSellingFilterBy == null || TopSellingFilterBy == Constants.DEFAULT_VALUE_INT)
            {
                result.reportName = "All Categories";
            }
            else
            {
                ETC.Category category = ETC.Category.ExecuteCreate(TopSellingFilterBy.Value);

                if (category != null)
                {
                    result.reportName = category.Name;
                }
                else
                {
                    result = null;
                }
            }

            return(result);
        }