public ActionResult Create(CreateOrEditProductViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Product product = new Product
                    {
                        Name = model.Name,
                        Price = model.Price
                    };

                    //_db.Products.Add(product);
                    //_db.SaveChanges();

                    //return RedirectToAction("Index");
                    return Content(Boolean.TrueString);
                }

                //return View(category);
                //return PartialView("_Add", category);
                return Content("Please review your form.");
            }
            catch (Exception ex)
            {
                return Content("Error Occured!");
            }
        }
        public ActionResult FilterDialog(Product product)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    return Content(Boolean.TrueString);
                }

                return Content("Please review your form.");
            }
            catch (Exception ex)
            {
                return Content("Error Occured!");
            }
        }
        public JsonResult Edit(Product product)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var model = _db.Products.Find(product.ProductId);

                    if (model != null)
                    {
                        model.Name = product.Name;
                        model.Price = product.Price;
                        model.CategoryId = product.CategoryId;

                        _db.Entry(model).State = EntityState.Modified;
                        _db.SaveChanges();

                        //return RedirectToAction("Index");
                        //return Content(Boolean.TrueString);
                        //return Json("Success", JsonRequestBehavior.AllowGet);
                        return Json(new { msg = "Product updated successfully.", status = MessageType.success.ToString() }, JsonRequestBehavior.AllowGet);
                    }

                    return Json(new { msg = "Product is null.", status = MessageType.info.ToString() }, JsonRequestBehavior.AllowGet);

                }

                //ViewBag.CategoryId = new SelectList(_db.Categories, "CategoryId", "Name", product.CategoryId);

                //return View(product);
                //return View("_Edit", product);
                //return Content("Please review your form.");
                //return Json("Success", JsonRequestBehavior.AllowGet);
                return Json(new { msg = ExceptionHelper.ModelStateErrorFormat(ModelState), status = MessageType.info.ToString() }, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                //return Content("Error Occured!");
                //return Json("Success", JsonRequestBehavior.AllowGet);
                return Json(new { msg = ExceptionHelper.ExceptionMessageFormat(ex), status = MessageType.error.ToString() }, JsonRequestBehavior.AllowGet);
            }
        }
        public JsonResult Create(Product product)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _db.Products.Add(product);
                    _db.SaveChanges();

                    //return RedirectToAction("Index");
                    //return Content(Boolean.TrueString);
                    //return Json("Success", JsonRequestBehavior.AllowGet);
                    return Json(new { msg = "Product saved successfully.", status = MessageType.success.ToString() }, JsonRequestBehavior.AllowGet);
                }

                //ViewBag.CategoryId = new SelectList(_db.Categories, "CategoryId", "Name", product.CategoryId);

                //return View(product);
                //return View("_Create", product);
                //return Content("Please review your form.");
                //return Json("Success", JsonRequestBehavior.AllowGet);

                return Json(new { msg = ExceptionHelper.ModelStateErrorFormat(ModelState), status = MessageType.info.ToString() }, JsonRequestBehavior.AllowGet);

            }
            catch (Exception ex)
            {
                //return Content("Error Occured!");
                //return Json("Success", JsonRequestBehavior.AllowGet);
                return Json(new { msg = ExceptionHelper.ExceptionMessageFormat(ex, log: true), status = MessageType.error.ToString() }, JsonRequestBehavior.AllowGet);
            }
        }