예제 #1
0
        public ActionResult AddOrEditProductVariation(Guid?id)
        {
            try
            {
                var model = new ProVarationViewModel();

                model.DropDownProduct = DropDownListDomain.DropDownList_Product(_productService.SelectAll());
                model.DropDownVolume  = DropDownListDomain.DropDownList_Volume();

                if (id.HasValue)
                {
                    var productVariation = _productVariationService.GetById(id.Value);

                    model = ConvertDomainToModel.ConvertModelFromDomainToProVa(productVariation);

                    model.DropDownProduct = DropDownListDomain.DropDownList_Product(_productService.SelectAll());
                    model.DropDownVolume  = DropDownListDomain.DropDownList_Volume();

                    model.Image = _productImageService.GetProductImage(model.Id) == null ? null :
                                  ConvertDomainToModel.GetProductImage(_productImageService.GetProductImage(model.Id));

                    return(View(model));
                }
                else
                {
                    return(View(model));
                }
            }
            catch { return(RedirectToAction("Erorr500", "HomdeAdmin")); }
        }
        public ActionResult AddOrEditCategory(Guid?id)
        {
            try
            {
                CategoryViewModel model = new CategoryViewModel();

                model.DropDownCategory = DropDownListDomain.DropDownList_Categoty(_categoryService.SelectAll().OrderBy(p => p.Name).ToList());
                model.DropDownProduct  = DropDownListDomain.DropDownList_Product(_productService.SelectAll().OrderBy(p => p.Name).ToList());

                if (id.HasValue)
                {
                    var category = _categoryService.GetById(id.Value);
                    model.Id          = category.Id;
                    model.Name        = category.Name;
                    model.ParentId    = category.ParentId;
                    model.Summary     = category.Summary;
                    model.UpdatedDate = category.UpdatedDate;
                    model.CreatedDate = category.CreatedDate;
                    model.IsActive    = category.IsActive;
                    return(View(model));
                }
                else
                {
                    return(View(model));
                }
            }
            catch { return(RedirectToAction("Erorr500", "HomdeAdmin")); }
        }