public Categories Add(CategoriesViewModel categories)
        {
            if (categories == null)
            {
                throw new ArgumentNullException("categories");
            }
            Categories newCategory = new Categories();
            AutoMapper.Mapper.Map(categories, newCategory);
            this.db.Categories.Add(newCategory);
            this.db.SaveChanges();

            return newCategory;
        }
        public Categories Update(CategoriesViewModel categories)
        {
            if (categories == null)
            {
                throw new ArgumentNullException("categories");
            }
            Categories newCategory = new Categories();
            AutoMapper.Mapper.Map(categories, newCategory);
            this.db.Entry(newCategory).State = EntityState.Modified;
            this.db.SaveChanges();

            return newCategory;
        }
 public ActionResult Edit(CategoriesViewModel categories)
 {
     this.service.Update(categories);
     return RedirectToAction("Index");
 }
 public ActionResult Create(CategoriesViewModel categories)
 {
     this.service.Add(categories);
     return RedirectToAction("Index");
 }
 public ActionResult Update([DataSourceRequest] DataSourceRequest request, CategoriesViewModel categories)
 {
     this.service.Update(categories);
     return Json(ModelState.ToDataSourceResult());
 }
 public ActionResult Delete([DataSourceRequest] DataSourceRequest request, CategoriesViewModel categories)
 {
     var id = categories.CategoryID;
     this.service.Delete(id);
     return Json(ModelState.ToDataSourceResult());
 }
 public ActionResult Add([DataSourceRequest] DataSourceRequest request, CategoriesViewModel categories)
 {
     var newcategory = this.service.Add(categories);
     return Json(new[] { newcategory }.ToDataSourceResult(request, ModelState));
 }