public ActionResult SaveAssignLocationandRolesPermissions(PermissionDetailsModel objPermissionDetails) { DARModel objDAR = null; eTracLoginModel ObjLoginModel = null; try { AlertMessageClass ObjAlertMessageClass = new AlertMessageClass(); if (objPermissionDetails != null && objPermissionDetails.LocationId > 0 && objPermissionDetails.UserIds != null) { if (Session["eTrac"] != null) { ObjLoginModel = (eTracLoginModel)(Session["eTrac"]); if (ObjLoginModel != null) { objPermissionDetails.CreatedBy = ObjLoginModel.UserId; objPermissionDetails.CreatedOn = DateTime.UtcNow; objDAR = new DARModel(); objDAR.LocationId = objPermissionDetails.LocationId; objDAR.UserId = ObjLoginModel.UserId; objDAR.CreatedBy = ObjLoginModel.UserId; objDAR.CreatedOn = DateTime.UtcNow; objDAR.TaskType = (long)TaskTypeCategory.AssignLocationPermission; objPermissionDetails.FullName = objPermissionDetails.FullName.ToTitleCase(); switch (objPermissionDetails.UserType) { case 2: { objDAR.ActivityDetails = DarMessage.LocationAssignedManager(objPermissionDetails.FullName, objPermissionDetails.LocationName); break; } case 3: { objDAR.ActivityDetails = DarMessage.LocationAssignedEmployee(objPermissionDetails.FullName, objPermissionDetails.LocationName); break; } case 4: { objDAR.ActivityDetails = DarMessage.LocationAssigned(objPermissionDetails.FullName, objPermissionDetails.LocationName); break; } case 5: { objDAR.ActivityDetails = DarMessage.LocationAssigned(objPermissionDetails.FullName, objPermissionDetails.LocationName); break; } case 6: { objDAR.ActivityDetails = DarMessage.LocationAssignedAdmin(objPermissionDetails.FullName, objPermissionDetails.LocationName); break; } default: { objDAR.ActivityDetails = "Something went wrong"; break; } } var result = _ICommonMethod.AssignLocationRoles(objPermissionDetails, objDAR, ObjLoginModel.UserId); if (result == Result.Completed) { ViewBag.Message = CommonMessage.SaveSuccessMessage(); ViewBag.AlertMessageClass = ObjAlertMessageClass.Success; ModelState.Clear(); } else { ViewBag.Message = CommonMessage.FailureMessage(); ViewBag.AlertMessageClass = ObjAlertMessageClass.Danger;// store the failure message in tempdata to display in view. } return(Json(new { Message = ViewBag.Message, AlertMessageClass = ViewBag.AlertMessageClass }, JsonRequestBehavior.AllowGet)); } else { return(Json("NotRegistered")); } } else { return(Json("Session Expired !")); } } else { ViewBag.Message = CommonMessage.FillAllRequired(); ViewBag.AlertMessageClass = ObjAlertMessageClass.Danger;// store the failure message in tempdata to display in view. } return(Json(new { Message = ViewBag.Message, AlertMessageClass = ViewBag.AlertMessageClass }, JsonRequestBehavior.AllowGet)); } catch (Exception) { ViewBag.Message = CommonMessage.FailureMessage(); ViewBag.AlertMessageClass = "text-danger";// store the failure message in tempdata to display in view. return(Json(new { Message = ViewBag.Message, AlertMessageClass = ViewBag.AlertMessageClass }, JsonRequestBehavior.AllowGet)); } }