public ValidationResult ManipulateUserLevel(SEC_UserLevel userLevel, string action, out string status) { _userLevelDataService.ManipulateUserLevel(userLevel, action, out status); return(status.Length > 0 ? new ValidationResult(status, _localizationService.GetResource(status)) : ValidationResult.Success); }
public async Task <dynamic> EditUserLevel(SEC_UserLevel objUserLevel) { if (ModelState.IsValid) { _action = "edit"; objUserLevel.SetBy = "16012500001";//Session["UserId"].ToString(); objUserLevel.ModifiedBy = objUserLevel.SetBy; _respStatus = await Task.Run(() => _userLevelService.ManipulateUserLevel(objUserLevel, _action, out _outStatus)); return(Json(new { Message = _respStatus.Message, _respStatus }, JsonRequestBehavior.AllowGet)); } _respStatus = new ValidationResult("E404", _localizationService.GetResource("E404")); return(Json(new { Message = _respStatus.Message, _respStatus }, JsonRequestBehavior.AllowGet)); }
public string ManipulateUserLevel(SEC_UserLevel userLevel, string action, out string errorNumber) { errorNumber = string.Empty; try { var factory = new DatabaseProviderFactory(); var db = factory.CreateDefault() as SqlDatabase; using (var dbCommandWrapper = db.GetStoredProcCommand("SetUserLevel")) { // Set parameters db.AddInParameter(dbCommandWrapper, "@UserLevelID", SqlDbType.VarChar, userLevel.ID); db.AddInParameter(dbCommandWrapper, "@UserLevel", SqlDbType.Int, userLevel.UserLevel); db.AddInParameter(dbCommandWrapper, "@UserLevelName", SqlDbType.VarChar, userLevel.UserLevelName); db.AddInParameter(dbCommandWrapper, "@UserLevelSL", SqlDbType.VarChar, userLevel.UserLevelSL); db.AddInParameter(dbCommandWrapper, "@UserLevelType", SqlDbType.VarChar, userLevel.UserLevelType); db.AddInParameter(dbCommandWrapper, "@SetBy", SqlDbType.VarChar, userLevel.SetBy); db.AddInParameter(dbCommandWrapper, "@ModifiedBy", SqlDbType.VarChar, userLevel.ModifiedBy); db.AddInParameter(dbCommandWrapper, "@Status", SqlDbType.Int, userLevel.Status); db.AddInParameter(dbCommandWrapper, "@Action", SqlDbType.VarChar, action); db.AddInParameter(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 { errorNumber = "E404"; // Log ex.Message Insert Log Table } return(errorNumber); }