public void GetAlertNotificationTypes_Success() { IAlertsDal dal = PrepareAlertsDal(); IAlertsDalGetAlertNotificationTypesParams getTypesParams = dal.CreateGetAlertNotificationTypesParams(); var getTypesResult = dal.GetAlertNotificationTypes(getTypesParams); Assert.IsTrue(getTypesResult.Success); Assert.IsNotNull(getTypesResult.Types != null); Assert.IsNotEmpty(getTypesResult.Types); }
public IAlertsDalGetAlertNotificationTypesResult GetAlertNotificationTypes(IAlertsDalGetAlertNotificationTypesParams getParams) { IAlertsDalGetAlertNotificationTypesResult result = new MSSQL.AlertsDalGetAlertNotificationTypesResult(); string spName = "[SP_Get_Alert_Notification_Types]"; SqlConnection conn = OpenConnection(connName); SqlCommand cmd = new SqlCommand(); cmd.CommandText = schema + "." + spName; cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = conn; try { DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; da.Fill(ds); if (ds != null && ds.Tables != null && ds.Tables.Count > 0) { foreach (DataRow r in ds.Tables[0].Rows) { AlertNotificationType type = new AlertNotificationType(); type.ID = (long)r["Alert_Notification_Type_Id"]; type.Value = !DBNull.Value.Equals(r["Alert_Notification_Type_Value"]) ? (string)r["Alert_Notification_Type_Value"] : null; result.Types.Add(type); } } } catch (Exception ex) { result.Success = false; result.Errors.Add(new Interfaces.Error() { Code = Interfaces.EErrorCodes.AlertsSourceFail, Type = Interfaces.EErrorType.Error, Message = ex.Message }); } conn.Close(); return(result); }
public object Any(GetNotificationTypes request) { GetNotificationTypesResponse response = new GetNotificationTypesResponse(); TransferHeader(request, response); try { IAlertsDalGetAlertNotificationTypesParams getParams = _dal.CreateGetAlertNotificationTypesParams(); var getResult = _dal.GetAlertNotificationTypes(getParams); if (getResult.Success) { foreach (var at in getResult.Types) { response.Payload.Types.Add(new DTO.NotificationType() { ID = at.ID, Name = at.Value }); } response.Success = true; } } catch (Exception ex) { response.Success = false; response.Errors.Add(new Interfaces.Error() { Code = Interfaces.EErrorCodes.GeneralError, Type = Interfaces.EErrorType.Error, Message = ex.Message }); } return(response); }