public ActionResult AddProblemObserved()
        {
            var problemobserved = new ManageProblemObserved();

            using (var con = new SqlConnection(_connectionString))
            {
                problemobserved.CategoryList    = new SelectList(dropdown.BindCategory(CurrentUser.CompanyId), "Value", "Text");
                problemobserved.SubCategoryList = new SelectList(dropdown.BindSubCategory(), "Value", "Text");

                //var result = con.Query<int>("select coalesce(MAX(SortOrder),0) from MstProblemObserved", null, commandType: CommandType.Text).FirstOrDefault();
                //ViewBag.SortOrder = result + 1;
                return(PartialView(problemobserved));
            }
        }
 public ActionResult AddProblemObserved(ManageProblemObserved model)
 {
     using (var con = new SqlConnection(_connectionString))
     {
         if (model.ProblemObserved == null)
         {
         }
         else
         {
             var result = con.Query <int>("Add_Edit_ProblemObserved",
                                          new {
                 ProblemId      = "",
                 DeviceCategory = model.Device_Category,
                 model.SubCategory,
                 model.ProblemCode,
                 model.ProblemObserved,
                 model.IsActive,
                 model.SortOrder,
                 User = CurrentUser.UserId,
                 CurrentUser.CompanyId,
                 Action = "add"
             },
                                          commandType: CommandType.StoredProcedure).FirstOrDefault();
             var response = new ResponseModel();
             if (result == 1)
             {
                 response.IsSuccess   = true;
                 response.Response    = "Successfully Added";
                 TempData["response"] = response;
             }
             else
             {
                 response.IsSuccess   = true;
                 response.Response    = "Problem Code Already Exist";
                 TempData["response"] = response;
             }
         }
         return(RedirectToAction("ManageProblemObserved"));
     }
 }