コード例 #1
0
        public JsonResult EditModal(Category model)
        {
            Category temp = CategoryDAL.Get(x => x.CategoryID == model.CategoryID);

            temp.IsActive = false;
            CategoryDAL.Update(temp);

            Category temp2 = new Category()
            {
                CategoryID    = Guid.NewGuid(),
                CategoryName  = model.CategoryName,
                Description   = model.Description,
                IsActive      = true,
                SubCategoryID = temp.SubCategoryID,
            };

            foreach (Make item in temp.Makes)
            {
                temp2.Makes.Add(item);
            }
            foreach (ProductModel item in temp.ProductModels)
            {
                temp2.ProductModels.Add(item);
            }
            foreach (Property item in temp.Properties)
            {
                temp2.Properties.Add(item);
            }


            CategoryDAL.Add(temp2);

            return(Json(true));
        }
コード例 #2
0
        public ActionResult Edit(VMCategory model, Guid CategoryID, Guid id)
        {
            Category cat = CategoryDAL.Get(x => x.CategoryID == id);

            cat.IsActive = false;
            CategoryDAL.Update(cat);

            Category c = new Category();

            c.CategoryID    = Guid.NewGuid();
            c.CategoryName  = model.Category.CategoryName;
            c.Description   = model.Category.Description;
            c.SubCategoryID = CategoryID;
            c.IsActive      = true;

            foreach (var item in cat.Makes)
            {
                c.Makes.Add(item);
            }
            foreach (var item in cat.Properties)
            {
                c.Properties.Add(item);
            }
            foreach (var item in cat.ProductModels)
            {
                c.ProductModels.Add(item);
            }

            CategoryDAL.Add(c);
            return(RedirectToAction("Index", "Category"));
        }
コード例 #3
0
 public JsonResult AddModal(Category model)
 {
     model.CategoryID = Guid.NewGuid();
     model.IsActive   = true;
     CategoryDAL.Add(model);
     return(Json(true));
 }
コード例 #4
0
        public ActionResult CategoryProcess(Category entity, HttpPostedFileBase file, string isNew)
        {
            if (file != null && file.ContentLength > 0 && file.ContentLength < 10485760)
            {
                string imagePath = new ImageUpload().ImageResize(file, 673, 483);

                if (isNew != "true")
                {
                    string filePath = Server.MapPath(entity.PictureUrl);
                    if (System.IO.File.Exists(filePath))
                    {
                        System.IO.File.Delete(filePath);
                    }
                }
                entity.PictureUrl = imagePath;
            }

            if (isNew == "true")
            {
                int result = catMng.Add(entity);
            }
            else
            {
                bool updateResult = catMng.Update(entity);
            }

            return(RedirectToAction("Kategoriİslemleri", "Category"));
        }
コード例 #5
0
 public IActionResult Add(CATEGORY CATEGORY)
 {
     if (CATEGORY.Id == 0)
     {
         _CategoryDAL.Add(CATEGORY);
     }
     else
     {
         _CategoryDAL.Update(CATEGORY);
     }
     return(Redirect("/Admin/Category/Index"));
 }
コード例 #6
0
        public ActionResult Add(Category model)
        {
            if (model.SubCategoryID == null)
            {
                model.SubCategoryID = Guid.Parse("35391ff3-c30d-4a6a-b30b-14079eaaa455");
            }
            model.CategoryID = Guid.NewGuid();
            model.IsActive   = true;
            if (ModelState.IsValid)
            {
                if (CategoryDAL.GetList(x => x.SubCategoryID == model.SubCategoryID && x.IsActive == true).Where(x => x.CategoryName == model.CategoryName).FirstOrDefault() == null)
                {
                    //bağlı tablolar taşınıyor...
                    Category tempCategory = CategoryDAL.Get(x => x.CategoryID == model.SubCategoryID && x.IsActive == true);
                    foreach (ProductModel item in tempCategory.ProductModels)
                    {
                        item.Category = model;
                    }
                    foreach (Property item in tempCategory.Properties)
                    {
                        model.Properties.Add(item);
                    }
                    tempCategory.Properties.Clear();
                    foreach (Make item in tempCategory.Makes)
                    {
                        model.Makes.Add(item);
                    }
                    tempCategory.Makes.Clear();
                    CategoryDAL.Add(model);
                }
                else
                {
                    VMCategory vmCat = new VMCategory();
                    Guid       temp  = Guid.Parse("35391ff3-c30d-4a6a-b30b-14079eaaa455");
                    vmCat.Categories = CategoryDAL.GetList(x => x.SubCategoryID == temp);
                    return(View(vmCat));
                }
            }
            else
            {
                VMCategory vmCat = new VMCategory();
                Guid       temp  = Guid.Parse("35391ff3-c30d-4a6a-b30b-14079eaaa455");
                vmCat.Categories = CategoryDAL.GetList(x => x.SubCategoryID == temp);
                return(View(vmCat));
            }

            return(RedirectToAction("Index", "Category"));
        }
コード例 #7
0
        private void btnAddCategories_Click(object sender, EventArgs e)
        {
            Category category = new Category()
            {
                Name = this.txbNameCategories.Text
            };

            bool isValid = ValidationOperation <Category> .ValidateOperation(category);

            if (isValid)
            {
                CategoryDAL categoryDAL = new CategoryDAL();
                categoryDAL.Add(category);
                MessageBox.Show("Successfully Added!");
                categoryDAL.GetGridData(dgvCategory);
            }
        }
コード例 #8
0
        public JsonResult PostCategory(CategroyVM vm)
        {
            string   message;
            Category category = new Category()
            {
                Name         = vm.Name,
                CreatedBy    = 1,
                CreationDate = DateTime.Now
            };

            return(Json(new
            {
                done = CategroyDAL.Add(category, out message),
                message,
                add = true
            },
                        JsonRequestBehavior.AllowGet));
        }
コード例 #9
0
        //点击 “确定”按钮
        private void btnOK_Click(object sender, EventArgs e)
        {
            string title = txtTitle.Text.Trim();

            var newCategory = new CategoryInfo()
            {
                CategoryName = title
            };

            if (_category == null)
            {
                //添加新的分类
                CategoryDAL.Add(newCategory);
            }
            else
            {
                //修改已有分类
                CategoryDAL.Update(_category.ID, newCategory);
            }
            //触发 DataChanged 事件
            OnDataChanged();
            Close();
        }
コード例 #10
0
 static public bool Add(Category category, out string msg)
 {
     return(CategoryDAL.Add(category, out msg));
 }
コード例 #11
0
 public bool AddCategory(Category category, byte[] image)
 {
     category.Image = image;
     return(categoryDAL.Add(category) > 0);
 }
コード例 #12
0
ファイル: CategoryBL.cs プロジェクト: PeerCohen/finalProject
 public static void Add(CategoryDTO category)
 {
     CategoryDAL.Add(CategoryCast.ToDAL(category));
 }
コード例 #13
0
 public void Add(CategoryDTO DTO)
 {
     DAL.Add(DTO);
 }
コード例 #14
0
ファイル: CategoryBLL.cs プロジェクト: yyan522/WebProject
 /// <summary>
 ///Add
 /// </summary>
 public int Add(Category model)
 {
     return(dal.Add(model));
 }