示例#1
0
        public ActionResult ProductAttributeFormPartialView(int?id)
        {
            if (id == null)
            {
                id = 0;
            }
            var modeldata = productCategoriesRepository.getProductAttributeById(id.Value);

            if (modeldata == null)
            {
                ProductAttributeModal objresult = new ProductAttributeModal();
                BindProductCategoryModel(objresult);
                return(View(objresult));
            }
            var result = new ProductAttributeModal()
            {
                AttributeId   = modeldata.AttributeId,
                ProdCatId     = modeldata.ProdCatId,
                AttributeName = modeldata.AttributeName
            };

            BindProductCategoryModel(result);
            result = result == null ? new ProductAttributeModal() : result;

            return(View(result));
        }
示例#2
0
 private void InsertUpdateProductAttribute(ProductAttributeModal model)
 {
     try
     {
         ProductAttribute productAttribute = new ProductAttribute();
         productAttribute.AttributeName = model.AttributeName;
         productAttribute.ProdCatId     = model.ProdCatId;
         productAttribute.AttributeId   = model.AttributeId;
         var result = productCategoriesRepository.InsertUpdateProductAttribute(productAttribute);
     }
     catch (Exception ex)
     { throw ex; }
 }
示例#3
0
        private void BindProductCategoryModel(ProductAttributeModal model)
        {
            model.ProductCategoryList = productCategoriesRepository.GetProductCategoryInfo(null, null, null, 1, int.MaxValue)
                                        .Select(x => new SelectListItem()
            {
                Text  = x.CategoryName,
                Value = x.ProdCatId.ToString()
            }).ToList();

            model.ProductCategoryList.Insert(0, new SelectListItem()
            {
                Text = "Select", Value = ""
            });
        }
示例#4
0
        public ActionResult SaveProductAttribute(ProductAttributeModal model)
        {
            List <string> messages       = new List <string>();
            bool          responseStatus = true;

            if (!ModelState.IsValid)
            {
                responseStatus = false;
                messages       = ModelState.Values
                                 .SelectMany(x => x.Errors)
                                 .Select(x => x.ErrorMessage)
                                 .ToList();
            }
            try
            {
                if (responseStatus && model.ProdCatId > 0 && productCategoriesRepository.getProductCategoryDetilsById(model.ProdCatId) != null)
                {
                    InsertUpdateProductAttribute(model);
                    responseStatus = true;
                    messages.Add("Product Category data inserted successfully.");
                }
                else if (responseStatus)
                {
                    InsertUpdateProductAttribute(model);

                    responseStatus = true;
                    messages.Add("Product Category data updated successfully.");
                }
            }
            catch (Exception ex)
            {
                responseStatus = false;
                messages.Add("something went wrong, please contact your administrator." + ex.Message);
            }


            return(Json(new { messages, responseStatus }, JsonRequestBehavior.AllowGet));
        }