public void GetAzureDedicatedCircuitSuccessful() { // Setup string circuitName = "TestCircuit"; uint bandwidth = 10; string serviceProviderName = "TestProvider"; string location = "us-west"; string serviceKey = "aa28cd19-b10a-41ff-981b-53c6bbf15ead"; BillingType billingType = BillingType.MeteredData; MockCommandRuntime mockCommandRuntime = new MockCommandRuntime(); Mock <ExpressRouteManagementClient> client = InitExpressRouteManagementClient(); var dcMock = new Mock <IDedicatedCircuitOperations>(); DedicatedCircuitGetResponse expected = new DedicatedCircuitGetResponse() { DedicatedCircuit = new AzureDedicatedCircuit() { CircuitName = circuitName, Bandwidth = bandwidth, BillingType = billingType.ToString(), Location = location, ServiceProviderName = serviceProviderName, ServiceKey = serviceKey, ServiceProviderProvisioningState = ProviderProvisioningState.NotProvisioned, Status = DedicatedCircuitState.Enabled, }, RequestId = "", StatusCode = new HttpStatusCode() }; var t = new Task <DedicatedCircuitGetResponse>(() => expected); t.Start(); dcMock.Setup(f => f.GetAsync(It.Is <string>(sKey => sKey == serviceKey), It.IsAny <CancellationToken>())).Returns((string sKey, CancellationToken cancellation) => t); client.SetupGet(f => f.DedicatedCircuits).Returns(dcMock.Object); GetAzureDedicatedCircuitCommand cmdlet = new GetAzureDedicatedCircuitCommand() { ServiceKey = Guid.Parse(serviceKey), CommandRuntime = mockCommandRuntime, ExpressRouteClient = new ExpressRouteClient(client.Object) }; cmdlet.ExecuteCmdlet(); // Assert AzureDedicatedCircuit actual = mockCommandRuntime.OutputPipeline[0] as AzureDedicatedCircuit; Assert.Equal <string>(expected.DedicatedCircuit.BillingType, actual.BillingType); Assert.Equal <string>(expected.DedicatedCircuit.CircuitName, actual.CircuitName); Assert.Equal <uint>(expected.DedicatedCircuit.Bandwidth, actual.Bandwidth); Assert.Equal <string>(expected.DedicatedCircuit.Location, actual.Location); Assert.Equal <string>(expected.DedicatedCircuit.ServiceProviderName, actual.ServiceProviderName); Assert.Equal(expected.DedicatedCircuit.ServiceProviderProvisioningState, actual.ServiceProviderProvisioningState); Assert.Equal(expected.DedicatedCircuit.Status, actual.Status); Assert.Equal <string>(expected.DedicatedCircuit.ServiceKey, actual.ServiceKey); }
public override int GetHashCode() { int hash = 1; if (BillingTier != global::Google.Cloud.SecurityCenter.Settings.V1Beta1.BillingTier.Unspecified) { hash ^= BillingTier.GetHashCode(); } if (BillingType != global::Google.Cloud.SecurityCenter.Settings.V1Beta1.BillingType.Unspecified) { hash ^= BillingType.GetHashCode(); } if (startTime_ != null) { hash ^= StartTime.GetHashCode(); } if (expireTime_ != null) { hash ^= ExpireTime.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
internal PurchaseMeterDetails(BillingType billingType, double?multiplier, ChargingType?chargingType, string productId, string skuId, string termId) : base(billingType, multiplier, chargingType) { ProductId = productId; SkuId = skuId; TermId = termId; BillingType = billingType; }
public List <BillingType> Search(SearchCriteria criteria) { SqlCommand command = null; SqlDataAdapter adapter = null; try { // Define command. command = mDbConnection.CreateCommand(); command.CommandText = "SearchBillingTypes"; command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("@Data", SqlDbType.Xml).Value = criteria.GetXml(); // Execute command. adapter = new SqlDataAdapter(command); DataTable billingTypeDataTable = new DataTable("BillingTypes"); adapter.Fill(billingTypeDataTable); // Create a list. List <BillingType> billingTypes = null; if (billingTypeDataTable.Rows.Count > 0) { billingTypes = new List <BillingType>(); } // Iterate each row. foreach (DataRow row in billingTypeDataTable.Rows) { // Create an instance of BillingType. BillingType billingType = new BillingType(Int32.Parse(row["BillingTypeId"].ToString())); billingType.Name = row["Name"].ToString(); billingType.Description = row["Description"].ToString(); billingType.Reason = row["Reason"].ToString(); billingType.IsActive = bool.Parse(row["IsActive"].ToString()); billingType.LastUpdateUserId = Int32.Parse(row["LastUpdateUserId"].ToString()); billingType.LastUpdateDate = DateTime.Parse(row["LastUpdateDate"].ToString()); billingType.CustomData.Add("LastUpdateUserName", row["LastUpdateUserName"].ToString()); // Add to list. billingTypes.Add(billingType); } // Return the list. return(billingTypes); } catch { throw; } finally { // Dispose. if (adapter != null) { adapter.Dispose(); } if (command != null) { command.Dispose(); } } }
private void Manage() { var billingtype = new BillingType { BillingTypeID = Convert.ToInt32(BillingTypeBAL.Manage(Request.QueryString)) }; Response.Write(billingtype.ToJSON()); }
public ActionResult DeleteConfirmed(int id) { BillingType billingType = db.BillingType.Find(id); db.BillingType.Remove(billingType); db.SaveChanges(); return(RedirectToAction("Index")); }
/// <summary> /// 该更余额 /// </summary> /// <param name="amount">需要变更的金额(大于0增加,小于0减少)</param> public void ChangeBalance(decimal amount, BillingType billingType, string payType = null, string desc = null) { if (amount < 0 && Balance < amount * -1) { throw new Exception("余额不足,扣费失败"); } Balance += amount; DomainEvents.Add(new OnCapitalBalanceChanged(this, billingType, amount, payType, desc)); }
public void Update(int id, string description, short autoPayDay, bool isActive) { BillingType bil = ctx.BillingTypes.Single(row => row.ID == id); bil.Description = description; bil.AutoPayDay = autoPayDay; bil.IsActive = isActive; EntityHelper.SetAuditFieldForUpdate(bil, HttpContext.Current.User.Identity.Name); ctx.SubmitChanges(); }
public ActionResult Edit([Bind(Include = "Id,TYPE")] BillingType billingType) { if (ModelState.IsValid) { db.Entry(billingType).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(billingType)); }
public void Update(int id, string description, short autoPayDay, bool isActive) { BillingType bil = context.BillingTypes.Single(row => row.ID == id); bil.Description = description; bil.AutoPayDay = autoPayDay; bil.IsActive = isActive; EntityHelper.SetAuditFieldForUpdate(bil, principal.Identity.Name); context.SaveChanges(); }
public ActionResult Create([Bind(Include = "Id,TYPE")] BillingType billingType) { if (ModelState.IsValid) { db.BillingType.Add(billingType); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(billingType)); }
public void Add(string description, short autoPayDay, bool isActive) { BillingType bil = new BillingType(); bil.Description = description; bil.AutoPayDay = autoPayDay; bil.IsActive = isActive; EntityHelper.SetAuditFieldForInsert(bil, principal.Identity.Name); context.Add(bil); context.SaveChanges(); }
public void Add(string description, short autoPayDay, bool isActive) { BillingType bil = new BillingType(); bil.Description = description; bil.AutoPayDay = autoPayDay; bil.IsActive = isActive; EntityHelper.SetAuditFieldForInsert(bil, HttpContext.Current.User.Identity.Name); ctx.BillingTypes.InsertOnSubmit(bil); ctx.SubmitChanges(); }
// GET: BillingTypes/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BillingType billingType = db.BillingType.Find(id); if (billingType == null) { return(HttpNotFound()); } return(View(billingType)); }
public static StripeBilling ToStripeBillingType(this BillingType billingType) { switch (billingType) { case BillingType.Automatic: return(StripeBilling.ChargeAutomatically); case BillingType.Manual: return(StripeBilling.SendInvoice); default: goto case BillingType.Automatic; } }
protected void gvwMaster_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "EditRow") { int id = Convert.ToInt32(e.CommandArgument); RowID = id; mvwForm.SetActiveView(viwAddEdit); BillingType billingType = billingTypeProvider.Get(id); txtDescription.Text = billingType.Description; txtAutoPayDay.Text = RowID > 1 ? billingType.AutoPayDay.ToString() : "N/A"; chkIsActive.Checked = billingType.IsActive; txtDescription.Focus(); btnSave.Enabled = RowID > 1; } }
public OnCapitalBalanceChanged([NotNull] Capital capital, [NotNull] BillingType billingType, decimal changedAmount, string payType, string desc) : base() { Check.NotNull(capital, nameof(capital)); Check.NotNullOrWhiteSpace(capital.AccountId, nameof(AccountId)); Check.NotNullOrWhiteSpace(capital.CapitalType, nameof(CapitalType)); Check.NotNull(billingType, nameof(BillingType)); AccountId = capital.AccountId; CapitalType = capital.CapitalType; Balance = capital.Balance; ChangedAmount = changedAmount; PayType = payType; Desc = desc; BillingType = billingType.Key; }
/// <summary> /// Отправка пользователю сообщения с благодарностью за совершенный донат /// либо оплату премиум аккаунта /// </summary> /// <param name="id">Идентификатор пользователя <see cref="DbUserProfile"/></param> /// <param name="sum">Оплаченная сумма</param> /// <param name="currency">Валюта совершенного платежа</param> /// <param name="type">Цель оплаты: премиум или донат</param> /// <returns> Void </returns> public async Task SendBillingUserAsync( string id, decimal sum, string currency, BillingType type) { if (currency == null) { throw new ArgumentNullException(nameof(currency)); } try { var user = _unitOfWork.UserAuthorisedRepository.Get( x => x.DbUser_Id == id, null, "DbUser").First(); // TODO: use nameof(DbUser), create method GetUser in UOW UserAuthorisedRepository var billing = Mapper.Map <BillingNotification>(user); billing.Sum = sum; billing.Currency = currency; string body; if (type == BillingType.Donate) { var template = _unitOfWork.EmailTemplateRepository.GetById( Convert.ToInt32(Resources.Donate)).Body; // TODO: (int)BillingType.Donate body = Engine.Razor.RunCompile(template, Resources.Donate, null, new { Donate = billing }); // TODO: (int)BillingType.Donate } else { var template = _unitOfWork.EmailTemplateRepository.GetById( // TODO: to param Convert.ToInt32(Resources.Premium)).Body; body = Engine.Razor.RunCompile( template, Resources.Premium, null, new { Premium = billing }); } var message = CreateMessage(billing.Receiver, body); await SendEmailAsync(_transport.ElementAt(0), new[] { message }); } catch (Exception exception) { _logger.Error(exception.Message); } }
private string BillTypeToStr(BillingType BillTypeToStr) { switch (BillTypeToStr) { case BillingType.Billable: return("Billable"); case BillingType.Capitalized: return("Capitalized"); case BillingType.FixedCost: return("Fixed Cost"); case BillingType.NonBillable: return("Non-Billable"); case BillingType.StartUpExpensed: return("Start-Up Expensed"); } return(""); }
public static string Manage(NameValueCollection querystring) { string isInsert = querystring.Get("TransType"); int intParser; UserProfile userProfile = WebCommon.GetUserProfile(); var billingtype = new BillingType { BillingTypeID = int.TryParse(querystring.Get("BillingTypeID"), out intParser) ? intParser : 0, Code = querystring.Get("Code"), Description = querystring.Get("Description"), Particulars = querystring.Get("Particulars"), Status = int.TryParse(querystring.Get("Status"), out intParser) ? intParser : 0, UserID = userProfile.UserId }; string param = WebCommon.ToXML(billingtype); return(BillingTypeDAL.Manage(param, isInsert)); }
public static List <BillingType> GetBillingType(string criteria) { var dbUtil = new DatabaseManager(); var billingtypes = new List <BillingType>(); using (var conn = new SqlConnection(dbUtil.getSQLConnectionString("MainDB"))) { conn.Open(); using (SqlCommand cmd = conn.CreateCommand()) { cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "spMasGetBillingType"; cmd.CommandTimeout = 180; cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@strCriteria", criteria); using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { var billingtype = new BillingType { BillingTypeID = ReferenceEquals(reader["intBillingTypeID"], DBNull.Value) ? 0 : (int)reader["intBillingTypeID"], Code = ReferenceEquals(reader["strCode"], DBNull.Value) ? String.Empty : (string)reader["strCode"], Description = ReferenceEquals(reader["strDescription"], DBNull.Value) ? String.Empty : (string)reader["strDescription"], Particulars = ReferenceEquals(reader["strParticulars"], DBNull.Value) ? String.Empty : (string)reader["strParticulars"], Status = ReferenceEquals(reader["intStatus"], DBNull.Value) ? 0 : (int)reader["intStatus"] }; billingtypes.Add(billingtype); } return(billingtypes); } } } }
public void NewAzureDedicatedCircuitSuccessful() { // Setup string circuitName = "TestCircuit"; uint bandwidth = 10; string serviceProviderName = "TestProvider"; string location = "us-west"; string serviceKey = "aa28cd19-b10a-41ff-981b-53c6bbf15ead"; BillingType billingType = BillingType.MeteredData; CircuitSku sku = CircuitSku.Premium; MockCommandRuntime mockCommandRuntime = new MockCommandRuntime(); Mock <ExpressRouteManagementClient> client = InitExpressRouteManagementClient(); var dcMock = new Mock <IDedicatedCircuitOperations>(); DedicatedCircuitGetResponse expected = new DedicatedCircuitGetResponse() { DedicatedCircuit = new AzureDedicatedCircuit() { CircuitName = circuitName, Bandwidth = bandwidth, BillingType = billingType.ToString(), Location = location, ServiceProviderName = serviceProviderName, ServiceKey = serviceKey, ServiceProviderProvisioningState = ProviderProvisioningState.NotProvisioned, Status = DedicatedCircuitState.Enabled, Sku = sku }, RequestId = "", StatusCode = new HttpStatusCode() }; var tGet = new Task <DedicatedCircuitGetResponse>(() => expected); tGet.Start(); ExpressRouteOperationStatusResponse expectedStatus = new ExpressRouteOperationStatusResponse() { HttpStatusCode = HttpStatusCode.OK, Data = serviceKey }; var tNew = new Task <ExpressRouteOperationStatusResponse>(() => expectedStatus); tNew.Start(); ExpressRouteOperationStatusResponse expectedUpdateStatus = new ExpressRouteOperationStatusResponse() { HttpStatusCode = HttpStatusCode.OK, Data = serviceKey }; var tUpdate = new Task <ExpressRouteOperationStatusResponse>(() => expectedUpdateStatus); tUpdate.Start(); dcMock.Setup(f => f.NewAsync(It.Is <DedicatedCircuitNewParameters>(x => x.Bandwidth == bandwidth && x.CircuitName == circuitName && x.Location == location && x.ServiceProviderName == serviceProviderName), It.IsAny <CancellationToken>())).Returns((DedicatedCircuitNewParameters param, CancellationToken cancellation) => tNew); dcMock.Setup(f => f.GetAsync(It.Is <string>(sKey => sKey == serviceKey), It.IsAny <CancellationToken>())).Returns((string sKey, CancellationToken cancellation) => tGet); dcMock.Setup(f => f.UpdateAsync(It.Is <string>(sKey => sKey == serviceKey), It.Is <DedicatedCircuitUpdateParameters>(y => y.Bandwidth == bandwidth.ToString() && y.BillingType == billingType && y.Sku == sku.ToString()), It.IsAny <CancellationToken>())).Returns((string sKey, DedicatedCircuitUpdateParameters updateParam, CancellationToken cancellation) => tUpdate); client.SetupGet(f => f.DedicatedCircuits).Returns(dcMock.Object); NewAzureDedicatedCircuitCommand cmdlet = new NewAzureDedicatedCircuitCommand() { CircuitName = circuitName, Bandwidth = bandwidth, BillingType = billingType, Location = location, ServiceProviderName = serviceProviderName, Sku = sku, CommandRuntime = mockCommandRuntime, ExpressRouteClient = new ExpressRouteClient(client.Object) }; cmdlet.ExecuteCmdlet(); // Assert AzureDedicatedCircuit actual = mockCommandRuntime.OutputPipeline[0] as AzureDedicatedCircuit; Assert.Equal <string>(expected.DedicatedCircuit.CircuitName, actual.CircuitName); Assert.Equal <string>(expected.DedicatedCircuit.BillingType, actual.BillingType); Assert.Equal <uint>(expected.DedicatedCircuit.Bandwidth, actual.Bandwidth); Assert.Equal <string>(expected.DedicatedCircuit.Location, actual.Location); Assert.Equal <string>(expected.DedicatedCircuit.ServiceProviderName, actual.ServiceProviderName); Assert.Equal(expected.DedicatedCircuit.ServiceProviderProvisioningState, actual.ServiceProviderProvisioningState); Assert.Equal(expected.DedicatedCircuit.Status, actual.Status); Assert.Equal <string>(expected.DedicatedCircuit.ServiceKey, actual.ServiceKey); Assert.Equal <CircuitSku>(expected.DedicatedCircuit.Sku, actual.Sku); SetAzureDedicatedCircuitPropertiesCommand setCmdlet = new SetAzureDedicatedCircuitPropertiesCommand() { ServiceKey = Guid.Parse(actual.ServiceKey), Bandwidth = bandwidth, BillingType = billingType, Sku = sku, CommandRuntime = mockCommandRuntime, ExpressRouteClient = new ExpressRouteClient(client.Object) }; setCmdlet.ExecuteCmdlet(); actual = mockCommandRuntime.OutputPipeline[0] as AzureDedicatedCircuit; Assert.Equal <string>(expected.DedicatedCircuit.CircuitName, actual.CircuitName); Assert.Equal <string>(expected.DedicatedCircuit.BillingType, actual.BillingType); Assert.Equal <uint>(expected.DedicatedCircuit.Bandwidth, actual.Bandwidth); Assert.Equal <string>(expected.DedicatedCircuit.Location, actual.Location); Assert.Equal <string>(expected.DedicatedCircuit.ServiceProviderName, actual.ServiceProviderName); Assert.Equal(expected.DedicatedCircuit.ServiceProviderProvisioningState, actual.ServiceProviderProvisioningState); Assert.Equal(expected.DedicatedCircuit.Status, actual.Status); Assert.Equal <string>(expected.DedicatedCircuit.ServiceKey, actual.ServiceKey); Assert.Equal <CircuitSku>(expected.DedicatedCircuit.Sku, actual.Sku); }
public AzureDedicatedCircuit NewAzureDedicatedCircuit(string circuitName, UInt32 bandwidth, string location, string serviceProviderName, CircuitSku sku, BillingType billingType) { var result = Client.DedicatedCircuits.New(new DedicatedCircuitNewParameters() { Bandwidth = bandwidth, CircuitName = circuitName, Location = location, ServiceProviderName = serviceProviderName, Sku = sku, BillingType = billingType }); if (result.HttpStatusCode.Equals(HttpStatusCode.OK)) { return(GetAzureDedicatedCircuit(new Guid(result.Data))); } else { throw new Exception(result.Error.ToString()); } }
protected async void CreateBillEntry() { Billing bill = null; if (!revenue.dueDate.HasValue) { await JSRuntime.InvokeVoidAsync("alert", "Due date is required."); return; } if (BillingType.Equals("MB")) { bill = await appDBContext.Billings .Include(b => b.propertyDirectory) .Where(b => b.propertyDirectory.propertyId.Equals(revenue.propertyId) && b.propertyDirectory.tenandId.Equals(revenue.tenantId) && revenue.dueDate.Value >= b.propertyDirectory.dateFrom && revenue.dueDate.Value <= b.propertyDirectory.dateTo && b.companyId.Equals(CompanyId) && b.billType.Equals(BillingType) && b.MonthYear.Equals(revenue.dueDate.Value.ToString("yyyyMM")) ).FirstOrDefaultAsync(); } //if(bill!=null) //{ // revenue.billingDocumentId = bill.documentId; // revenue.billingId = bill.billId.ToString(); // if(bill.balance>0) // { // this.revenue.amount = bill.balance; // this.revenue.checkAmount = bill.balance; // } // StateHasChanged(); // return; //} var pd = await appDBContext.PropertyDirectory .Where(b => b.propertyId.Equals(revenue.propertyId) && b.tenandId.Equals(revenue.tenantId) && revenue.dueDate.Value >= b.dateFrom && revenue.dueDate.Value <= b.dateTo && b.companyId.Equals(CompanyId)).FirstOrDefaultAsync(); if (pd == null) { await JSRuntime.InvokeVoidAsync("alert", "Tenant is not currently renting the selected property."); return; } var billingId = bill == null ? string.Empty : bill.billId.ToString(); BillingEntry.InitParameters(revenue.propertyId, revenue.tenantId, revenue.dueDate, BillingType, billingId); await BillingEntry.InitNewBilling(); BillingEntry.OpenDialogBox(); StateHasChanged(); }
/// <summary> /// Converts the <see cref="sourceValue" /> parameter to the <see cref="destinationType" /> parameter using <see cref="formatProvider" /// /> and <see cref="ignoreCase" /> /// </summary> /// <param name="sourceValue">the <see cref="System.Object"/> to convert from</param> /// <param name="destinationType">the <see cref="System.Type" /> to convert to</param> /// <param name="formatProvider">not used by this TypeConverter.</param> /// <param name="ignoreCase">when set to <c>true</c>, will ignore the case when converting.</param> /// <returns> /// an instance of <see cref="BillingType" />, or <c>null</c> if there is no suitable conversion. /// </returns> public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => BillingType.CreateFrom(sourceValue);
internal Pav2MeterDetails(BillingType billingType, double?multiplier, ChargingType?chargingType, string meterGuid) : base(billingType, multiplier, chargingType) { MeterGuid = meterGuid; BillingType = billingType; }
public void ListAzureDedicatedCircuitSuccessful() { // Setup string circuitName1 = "TestCircuit"; uint bandwidth1 = 10; string serviceProviderName1 = "TestProvider"; string location1 = "us-west"; string serviceKey1 = "aa28cd19-b10a-41ff-981b-53c6bbf15ead"; BillingType billingType1 = BillingType.MeteredData; string circuitName2 = "TestCircuit2"; uint bandwidth2 = 10; string serviceProviderName2 = "TestProvider"; string location2 = "us-north"; string serviceKey2 = "bc28cd19-b10a-41ff-981b-53c6bbf15ead"; BillingType billingType2 = BillingType.UnlimitedData; MockCommandRuntime mockCommandRuntime = new MockCommandRuntime(); Mock <ExpressRouteManagementClient> client = InitExpressRouteManagementClient(); var dcMock = new Mock <IDedicatedCircuitOperations>(); List <AzureDedicatedCircuit> dedicatedCircuits = new List <AzureDedicatedCircuit>() { new AzureDedicatedCircuit() { Bandwidth = bandwidth1, BillingType = billingType1.ToString(), CircuitName = circuitName1, ServiceKey = serviceKey1, Location = location1, ServiceProviderName = serviceProviderName1, ServiceProviderProvisioningState = ProviderProvisioningState.NotProvisioned, Status = DedicatedCircuitState.Enabled }, new AzureDedicatedCircuit() { Bandwidth = bandwidth2, BillingType = billingType2.ToString(), CircuitName = circuitName2, ServiceKey = serviceKey2, Location = location2, ServiceProviderName = serviceProviderName2, ServiceProviderProvisioningState = ProviderProvisioningState.Provisioned, Status = DedicatedCircuitState.Enabled } }; DedicatedCircuitListResponse expected = new DedicatedCircuitListResponse() { DedicatedCircuits = dedicatedCircuits, StatusCode = HttpStatusCode.OK }; var t = new Task <DedicatedCircuitListResponse>(() => expected); t.Start(); dcMock.Setup(f => f.ListAsync(It.IsAny <CancellationToken>())).Returns((CancellationToken cancellation) => t); client.SetupGet(f => f.DedicatedCircuits).Returns(dcMock.Object); GetAzureDedicatedCircuitCommand cmdlet = new GetAzureDedicatedCircuitCommand() { CommandRuntime = mockCommandRuntime, ExpressRouteClient = new ExpressRouteClient(client.Object) }; cmdlet.ExecuteCmdlet(); // Assert IEnumerable <AzureDedicatedCircuit> actual = LanguagePrimitives.GetEnumerable(mockCommandRuntime.OutputPipeline).Cast <AzureDedicatedCircuit>(); Assert.Equal(actual.Count(), 2); }
internal MeterDetails(BillingType billingType, double?multiplier, ChargingType?chargingType) { BillingType = billingType; Multiplier = multiplier; ChargingType = chargingType; }
public void Update(BillingType entity) { SqlCommand command = null; SqlTransaction transaction = null; SqlDataAdapter adapter = null; try { // Define command. command = new SqlCommand(); command = mDbConnection.CreateCommand(); command.CommandText = "UpdateBillingTypes"; command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("@DataXml", SqlDbType.Xml).Value = entity.GetXml(); command.Parameters.Add("@hasError", SqlDbType.Bit).Direction = ParameterDirection.Output; //command.ExecuteNonQuery(); // execute transaction = mDbConnection.BeginTransaction(); command.Transaction = transaction; // fill error datatable adapter = new SqlDataAdapter(command); DataTable errorDataTable = new DataTable(); adapter.Fill(errorDataTable); // commit transaction.Commit(); // Get output parameters. bool hasError = bool.Parse(command.Parameters["@hasError"].Value.ToString()); if (hasError) { // Create exception instance. ValidationException exception = new ValidationException(string.Empty); if (errorDataTable != null) { StringBuilder message = new StringBuilder(); foreach (DataRow row in errorDataTable.Rows) { message.Append(string.Format("{1}", row["Name"].ToString(), row["Value"].ToString())); } exception.Data.Add("IsExists", message); } throw exception; } } catch (ValidationException ve) { throw ve; } catch { if (transaction != null) { if (transaction.Connection != null) { transaction.Rollback(); } } throw; } finally { // Dispose. if (transaction != null) { transaction.Dispose(); } if (command != null) { command.Dispose(); } } }
public List <BillingType> Retrieve(int[] ids) { SqlCommand command = null; SqlDataAdapter adapter = null; try { // Build xml. StringBuilder xml = new StringBuilder(); xml.Append("<BillingTypes>"); foreach (int element in ids) { xml.Append(string.Format("<BillingType><Id>{0}</Id></BillingType>", element)); } xml.Append("</BillingTypes>"); // Define command. command = mDbConnection.CreateCommand(); command.CommandText = "RetrieveBillingTypes"; command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("@Data", SqlDbType.Xml).Value = xml.ToString(); // Execute command. adapter = new SqlDataAdapter(command); DataTable billingTypeDataTable = new DataTable("BillingTypes"); adapter.Fill(billingTypeDataTable); // Create a list. List <BillingType> billingTypes = null; if (billingTypeDataTable.Rows.Count > 0) { billingTypes = new List <BillingType>(); } // Iterate each row. foreach (DataRow row in billingTypeDataTable.Rows) { // Create an instance of BillingType. BillingType billingType = new BillingType(Int32.Parse(row["BillingTypeId"].ToString())); billingType.Name = row["Name"].ToString(); billingType.Description = row["Description"].ToString(); billingType.Reason = row["Reason"].ToString(); billingType.IsActive = bool.Parse(row["IsActive"].ToString()); billingType.LastUpdateUserId = Int32.Parse(row["LastUpdateUserId"].ToString()); billingType.LastUpdateDate = DateTime.Parse(row["LastUpdateDate"].ToString()); billingType.CustomData.Add("LastUpdateUserName", row["LastUpdateUserName"].ToString()); // Add to list. billingTypes.Add(billingType); } // Return the list. return(billingTypes); } catch { throw; } finally { // Dispose. if (adapter != null) { adapter.Dispose(); } if (command != null) { command.Dispose(); } } }