Example #1
0
        /// <summary>
        /// Get
        /// Calls [usp_select_Usage]
        /// </summary>
        public override UsageDetails Get(System.Int32?usageId)
        {
            SqlConnection cn  = null;
            SqlCommand    cmd = null;

            try {
                cn                 = new SqlConnection(this.ConnectionString);
                cmd                = new SqlCommand("usp_select_Usage", cn);
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 30;
                cmd.Parameters.Add("@UsageId", SqlDbType.Int).Value = usageId;
                cn.Open();
                DbDataReader reader = ExecuteReader(cmd, CommandBehavior.SingleRow);
                if (reader.Read())
                {
                    //return GetUsageFromReader(reader);
                    UsageDetails obj = new UsageDetails();
                    obj.UsageId = GetReaderValue_Int32(reader, "UsageId", 0);
                    obj.Name    = GetReaderValue_String(reader, "Name", "");
                    return(obj);
                }
                else
                {
                    return(null);
                }
            } catch (SqlException sqlex) {
                //LogException(sqlex);
                throw new Exception("Failed to get Usage", sqlex);
            } finally {
                cmd.Dispose();
                cn.Close();
                cn.Dispose();
            }
        }
Example #2
0
        /// <summary>
        /// DropDown
        /// Calls [usp_dropdown_Usage]
        /// </summary>
        public override List <UsageDetails> DropDown()
        {
            SqlConnection cn  = null;
            SqlCommand    cmd = null;

            try {
                cn                 = new SqlConnection(this.ConnectionString);
                cmd                = new SqlCommand("usp_dropdown_Usage", cn);
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.CommandTimeout = 30;
                cn.Open();
                DbDataReader        reader = ExecuteReader(cmd);
                List <UsageDetails> lst    = new List <UsageDetails>();
                while (reader.Read())
                {
                    UsageDetails obj = new UsageDetails();
                    obj.UsageId = GetReaderValue_Int32(reader, "UsageId", 0);
                    obj.Name    = GetReaderValue_String(reader, "Name", "");
                    lst.Add(obj);
                    obj = null;
                }
                return(lst);
            } catch (SqlException sqlex) {
                //LogException(sqlex);
                throw new Exception("Failed to get Usages", sqlex);
            } finally {
                cmd.Dispose();
                cn.Close();
                cn.Dispose();
            }
        }
Example #3
0
        private static Usage PopulateFromDBDetailsObject(UsageDetails obj)
        {
            Usage objNew = new Usage();

            objNew.UsageId = obj.UsageId;
            objNew.Name    = obj.Name;
            return(objNew);
        }
Example #4
0
        public void SerializeUsageDetailsToJson()
        {
            var usageDetails = new UsageDetails
            {
                Currency  = "DKK",
                TotalCost = 0.32m
            };

            var resultJson = @"
{
    ""currency"": ""DKK"",
    ""total_cost"": 0.32
}
";

            AssertionHelpers.AssertTwoJsonStringsAreEqual(resultJson, usageDetails.ToJson());
        }
Example #5
0
        /// DropDown
        /// Calls [usp_dropdown_RequirementData]
        /// </summary>
        public override List <UsageDetails> ReqDropDown(string ReqType)
        {
            SqlConnection cn  = null;
            SqlCommand    cmd = null;

            try
            {
                cn              = new SqlConnection(this.ConnectionString);
                cmd             = new SqlCommand("usp_dropdown_RequirementData", cn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@Stype", SqlDbType.NVarChar).Value = ReqType;
                cmd.CommandTimeout = 30;
                cn.Open();
                DbDataReader        reader = ExecuteReader(cmd);
                List <UsageDetails> lst    = new List <UsageDetails>();
                while (reader.Read())
                {
                    UsageDetails obj = new UsageDetails();
                    obj.UsageId = GetReaderValue_Int32(reader, "Id", 0);
                    obj.Name    = GetReaderValue_String(reader, "ServiceName", "");
                    lst.Add(obj);
                    obj = null;
                }
                return(lst);
            }
            catch (SqlException sqlex)
            {
                //LogException(sqlex);
                throw new Exception("Failed to get Requirement Dropdown Data", sqlex);
            }
            finally
            {
                cmd.Dispose();
                cn.Close();
                cn.Dispose();
            }
        }
 public static string ToJson(this UsageDetails usageDetails)
 {
     return(JsonSerializer.Serialize(usageDetails, JsonSerializerOptionsFactory.CreateOptions()));
 }
 internal MessagesSentResponse(UsageDetails usageDetails, T messageResponseDetails)
 {
     UsageDetails           = usageDetails;
     MessageResponseDetails = messageResponseDetails;
 }