public string SetMenuOperations(SEC_MenuDetails menuDetails, string action, out string errorNumber) { errorNumber = String.Empty; try { DatabaseProviderFactory factory = new DatabaseProviderFactory(); SqlDatabase db = factory.CreateDefault() as SqlDatabase; using (DbCommand dbCommandWrapper = db.GetStoredProcCommand("SetMenuOperation")) { // Set parameters db.AddInParameter(dbCommandWrapper, "@MenuID", SqlDbType.NVarChar, menuDetails.MenuID.Trim()); db.AddInParameter(dbCommandWrapper, "@VisibleInRollMenu", SqlDbType.Bit, true); db.AddInParameter(dbCommandWrapper, "@OwnerID ", SqlDbType.NVarChar, menuDetails.Owner.OwnerID.Trim()); db.AddInParameter(dbCommandWrapper, "@UserID", SqlDbType.NVarChar, menuDetails.SetBy); db.AddInParameter(dbCommandWrapper, "@UserLevel", SqlDbType.Int, menuDetails.UserLevel); db.AddInParameter(dbCommandWrapper, "@Status", SqlDbType.Int, menuDetails.Status); db.AddInParameter(dbCommandWrapper, "@Action", SqlDbType.VarChar, action); db.AddOutParameter(dbCommandWrapper, spStatusParam, SqlDbType.VarChar, 10); // Execute SP. db.ExecuteNonQuery(dbCommandWrapper); // Getting output parameters and setting response details. if (!db.GetParameterValue(dbCommandWrapper, spStatusParam).IsNullOrZero()) { // Get the error number, if error occurred. errorNumber = db.GetParameterValue(dbCommandWrapper, spStatusParam).PrefixErrorCode(); } } } catch (Exception ex) { errorNumber = "E404"; // Log ex.Message Insert Log Table } return(errorNumber); }
public ValidationResult SetMenuOperations(SEC_MenuDetails menuDetails, string action, out string status) { navSetupService.SetMenuOperations(menuDetails, action, out status); if (status.Length > 0) { return(new ValidationResult(status, localizationService.GetResource(status))); } return(ValidationResult.Success); }
public async Task <dynamic> SetMenuOperations(SEC_MenuDetails objMenuDetails) { if (ModelState.IsValid) { action = "add"; //objMenuDetails.SetBy = Session["UserId"].ToString(); respStatus = await Task.Run(() => _menuSetupService.SetMenuOperations(objMenuDetails, action, out outStatus)); // Error handling. return(Json(new { Message = respStatus.Message, respStatus }, JsonRequestBehavior.AllowGet)); } else { respStatus = new ValidationResult("E404", _localizationService.GetResource("E404")); } return(Json(new { Message = respStatus.Message, respStatus }, JsonRequestBehavior.AllowGet)); }