public ViewResult UpdateCategory(int id)
        {
            ServiceCategory      category      = categoryDetails.GetCategoryById(id);                                     //Getting the category details from database
            ServiceCategoryModel categoryModel = AutoMapper.Mapper.Map <ServiceCategory, ServiceCategoryModel>(category); //Mapping the category to the model to show the existing details

            return(View(categoryModel));
        }
 public ActionResult SaveUpdateServiceCategory(ServiceCategoryModel model)
 {
     try
     {
         return(Json(new { result = 1, ID = model.SaveUpdateServiceCategory(model) }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { error = ex.Message }, JsonRequestBehavior.AllowGet));
     }
 }
 public ActionResult UpdateCategory([Bind(Include = "CategoryID, CategoryName")] ServiceCategoryModel categoryModel)
 {
     if (ModelState.IsValid)
     {
         ServiceCategory category = (ServiceCategory)categoryDetails.GetCategoryById(categoryModel.CategoryId); //Getting the objecct of the category by using the category id from the database
         category.CategoryName = categoryModel.CategoryName;                                                    //Updating the category name if any changes made
         categoryDetails.UpdateCategory(category);                                                              //Updating the database
         TempData["Message"] = "Category updated successfully!!";
     }
     return(View());
 }
 public ActionResult AddCategory(ServiceCategoryModel newCategory)
 {
     if (ModelState.IsValid)
     {
         bool CanAddCategory = categoryDetails.VerifyCategory(newCategory.CategoryName);
         if (CanAddCategory)
         {
             var category = AutoMapper.Mapper.Map <ServiceCategoryModel, ServiceCategory>(newCategory); //Automapping category details from model to entity
             categoryDetails.AddCategory(category);                                                     //Adding the category to the database
             return(RedirectToAction("DisplayCategories"));                                             //Redirecting after adding the category
         }
         TempData["Message"] = "Category already exists!!";
     }
     return(View());
 }
 public ServiceCategoryVM()
 {
     web      = new MasterServices(this);
     Category = new ServiceCategoryModel();
 }