Esempio n. 1
0
        public ActionResult AddExistsAttribute(int CategoryID, int AttributeID, bool UseInFilter)
        {
            string ErrorMessage = null;
            try
            {
                var refModel = new t_Ref_Attribute_Category() {
                    CategoryID = CategoryID,
                    AttributeID = AttributeID,
                    UseInFilter = UseInFilter,
                    Enable = true
                };
                db.RefAttrCategoryRepository.Insert(refModel);
                db.Save();
                AddAttributeForAllProductsSpecifiedCategory(AttributeID, CategoryID);
            }
            catch (Exception ex)
            {
                Logger.Instance.Error(
                    string.Format("При добавление нового атрибута продукта к категории произошла ошибка: {0} {1}",
                        ex.Message, ex.StackTrace));
                ErrorMessage = "Нельзя привязать уже существуующий атрибут к категории";
            }
            return RedirectToAction("BindAttribute", new { CatID = CategoryID, error = ErrorMessage });   

        }
Esempio n. 2
0
        public ActionResult UpdateAttributes(t_Ref_Attribute_Category model, int CategoryID)
        {
            if (ModelState.IsValid)
            {
                    db.RefAttrCategoryRepository.Update(model);
                    db.Save();
            }
            return RedirectToAction("BindAttribute", new { CatID = CategoryID });

        }
Esempio n. 3
0
        public ActionResult AddAttribute(int CategoryID, string Name, bool UseInFilter)
        {
                if (!string.IsNullOrEmpty(Name) && !string.IsNullOrWhiteSpace(Name))
                {
                    if (db.AttributeRepository.GetAll().Any(a => a.Name == Name))
                    {
                        string ErrorMessage =
                            "Вы пытаетесь добавить атрибут уже имеющийся в списке все атрибутов, выберите атрибут из списка ниже.";
                        return RedirectToAction("BindAttribute", new { CatID = CategoryID, error = ErrorMessage });
                    }

                    var model = new t_ProductAttribute(){ Name = Name };
                    var result = db.AttributeRepository.InsertReturn(model);
                    db.Save();

                    var refModel = new t_Ref_Attribute_Category()
                    {
                        CategoryID = CategoryID,
                        AttributeID = result.ID,
                        UseInFilter = UseInFilter,
                        Enable = true
                    };
                    db.RefAttrCategoryRepository.Insert(refModel);
                    db.Save();
                    try
                    {
                        AddAttributeForAllProductsSpecifiedCategory(result.ID, CategoryID);
                    }
                    catch (Exception ex)
                    {
                        Logger.Instance.Error(ex.Message);
                    }
                }

            return RedirectToAction("BindAttribute", new {CatID = CategoryID});
        }