예제 #1
0
        public JsonResult Create(Category category)
        {
            if (ModelState.IsValid)
            {
                if (category.ParentId.HasValue)
                {
                    var getCategory = categoryRepo.FindById(category.ParentId.Value);
                    category.ParentName = getCategory.Name;
                }

                category.CreatedBy = Request.Cookies["USER"].Value;
                category.CreationDate = DateTime.Now;
                categoryRepo.Insert(category);
                categoryRepo.Save();

                return Json(new { success = true });
            }
            return Json(category, JsonRequestBehavior.AllowGet);
        }
예제 #2
0
 public ActionResult Create()
 {
     var category = new Category();
     return PartialView("Create", category);
 }
예제 #3
0
 public ActionResult Edit(Category category)
 {
     if (ModelState.IsValid)
     {
         if (category.ParentId.HasValue)
         {
             var getCategory = categoryRepo.FindById(category.ParentId.Value);
             category.ParentName = getCategory.Name;
         }
         categoryRepo.Update(category);
         categoryRepo.Save();
         return Json(new { success = true });
     }
     return PartialView("Edit", category);
 }
예제 #4
0
 public void Delete(Category entity)
 {
     context.Categories.Remove(entity);
 }
예제 #5
0
 public void Update(Category entity)
 {
     context.Entry(entity).State = System.Data.Entity.EntityState.Modified;
 }
예제 #6
0
 public void Insert(Category entity)
 {
     context.Categories.Add(entity);
 }