Exemplo n.º 1
0
 //check unique key
 public JsonResult CheckForDuplication([Bind(Prefix = "ProductGroup.Product_Group_Name")] string Product_Group_Name, [Bind(Prefix = "ProductGroup.Product_Group_Id")] int?Product_Group_Id)
 {
     try
     {
         if (Product_Group_Id != null)
         {
             if (!(productgroupRepository.CheckDuplicateNameWithId(Convert.ToInt32(Product_Group_Id), Product_Group_Name)))
             {
                 return(Json("Sorry, Product Group Name already exists", JsonRequestBehavior.AllowGet));
             }
             else
             {
                 return(Json(true, JsonRequestBehavior.AllowGet));
             }
         }
         else
         {
             var data = productgroupRepository.CheckDuplicateName(Product_Group_Name);
             if (data != null)
             {
                 return(Json("Sorry, Product Group Name already exists", JsonRequestBehavior.AllowGet));
             }
             else
             {
                 return(Json(true, JsonRequestBehavior.AllowGet));
             }
         }
     }
     catch (Exception ex)
     {
         ExceptionHandler.LogException(ex);
         ViewBag.AppErrorMessage = ex.Message;
         return(Json(new { Error = ex.Message }, JsonRequestBehavior.AllowGet));
     }
 }