public void GetAlertTypes_Success() { IAlertsDal dal = PrepareAlertsDal(); IAlertsDalGetAlertTypesParams getTypesParams = dal.CreateGetAlertTypesParams(); var getTypesResult = dal.GetAlertTypes(getTypesParams); Assert.IsTrue(getTypesResult.Success); Assert.IsNotNull(getTypesResult.Types != null); Assert.IsNotEmpty(getTypesResult.Types); }
public IAlertsDalGetAlertTypesResult GetAlertTypes(IAlertsDalGetAlertTypesParams getParams) { IAlertsDalGetAlertTypesResult result = new MSSQL.AlertsDalGetAlertTypesResult(); string spName = "[SP_Get_Alert_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) { AlertType type = new AlertType(); type.ID = (long)r["Alert_Type_Id"]; type.Name = !DBNull.Value.Equals(r["Alert_Type_Name"]) ? (string)r["Alert_Type_Name"] : null; type.Desc = !DBNull.Value.Equals(r["Alert_Type_Desc"]) ? (string)r["Alert_Type_Desc"] : 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(GetAlertsTypes request) { GetAlertsTypesResponse response = new GetAlertsTypesResponse(); TransferHeader(request, response); try { IAlertsDalGetAlertTypesParams getParams = _dal.CreateGetAlertTypesParams(); var getResult = _dal.GetAlertTypes(getParams); if (getResult.Success) { foreach (var at in getResult.Types) { response.Payload.Types.Add(new DTO.AlertType() { ID = at.ID, Name = at.Name, Desc = at.Desc }); } response.Success = true; } else { response.Success = false; response.Errors.AddRange(getResult.Errors); } } 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); }