public void CorrectChangeIsGivenForValues() { ICurrency currency = new USDCurrency(); IChangeService changeService = new ChangeService(currency); List <CurrencyItem> change; //Changing $1 returns $1 change = changeService.ChangeList(1.00); Assert.True(change.Count == 1); Assert.True(change[0].Value == 1); //Changing $1.50 returns $1 and $0.50 change = changeService.ChangeList(1.50); Assert.True(change.Count == 2); Assert.True(change[0].Value == 1); Assert.True(change[1].Value == 0.5); //Chaning $0.04 returns 2 $0.02 change = changeService.ChangeList(0.04); Assert.True(change.Count == 2, "Expected 2 Got " + change.Count); Assert.True(0.04 == change.Sum(c => c.Value), "Expected 0.04 got " + change.Sum(c => c.Value)); Assert.True(change[0].Value == 0.02); Assert.True(change[1].Value == 0.02); }
public TransactionsServiceTests() { var configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json").Build(); TransactionService = new TransactionService(configuration); ChangeService = new ChangeService(new BillService(configuration), new CoinService(configuration), new TransactionService(configuration)); }
void ITypeDescriptorContext.OnComponentChanged() { ChangeService.OnComponentChanged( _designer.Component, _targetProperty, null, null); }
public async Task <IActionResult> CalculeChange(decimal valueToPay, decimal totalValue) { _logger.LogInformation($"Executando o método {nameof(CalculeChange)}"); var result = await ChangeService.GetChangeAsync(new PointOfSaleDomain.PointOfSale { ValueToPay = valueToPay, TotalValue = totalValue }); _logger.LogInformation($"Execução realizada com sucesso do método {nameof(CalculeChange)}"); return(Ok(result)); }
/// <inheritdoc /> bool ITypeDescriptorContext.OnComponentChanging() { try { ChangeService.OnComponentChanging(_designer.Component, _targetProperty); return(true); } catch (CheckoutException checkoutException) when(checkoutException == CheckoutException.Canceled) { return(false); } }
bool ITypeDescriptorContext.OnComponentChanging() { try { ChangeService.OnComponentChanging(designer.Component, targetProperty); } catch (CheckoutException exception) { if (exception != CheckoutException.Canceled) { throw; } return(false); } return(true); }
/// <summary> /// Called when the component is to be changed. /// </summary> /// <returns></returns> bool ITypeDescriptorContext.OnComponentChanging() { try { ChangeService.OnComponentChanging(_designer.Component, _targetProperty); } catch (CheckoutException checkoutException) { if (checkoutException == CheckoutException.Canceled) { return false; } throw; } return true; }
static void Main(string[] args) { string filePath = ConfigurationManager.AppSettings["FilePath"]; var updates = new List <BambooEmployee>(); var employeeService = new EmployeeService(); var changeService = new ChangeService(); ChangeContainer changes = changeService.GetChangedEmployees(); if (changes != null && changes.Employees != null) { foreach (KeyValuePair <string, ChangeEmployee> employee in changes.Employees) { BambooEmployee bambooEmployee = employeeService.GetEmployee(employee.Value.Id); updates.Add(bambooEmployee); } var fileWriter = new CsvUpdates(filePath); fileWriter.WriteToFile(updates, "BambooEmployeeUpdates.csv"); } }
// methods private async Task <bool> LoadRepositoriesAsync() { LoadStatus = "Loading Speakers..."; await SpeakerRepository.LoadAsync(); LoadStatus = "Loading Sessions..."; await SessionRepository.LoadAsync(); LoadStatus = "Getting Changes..."; await ChangeRepository.LoadAsync(); var changes = ChangeRepository.GetAll(); if (changes.Count > 0) { LoadStatus = "Applying Changes..."; ChangeService.ApplyChanges(changes); } return(true); }
private void OnMultilineChange(object sender, EventArgs e) { ChangeService.OnComponentChanging(Control, null); Control.Multiline = !Control.Multiline; ChangeService.OnComponentChanged(Control, null, null, null); }
public JsonResult MoveDate(CourseMoveDateModel model) { var logger = LogManager.GetLogger("Course"); var activityDate = Db.ActivityDates.SingleOrDefault(d => d.Id == model.ActivityDateId); activityDate.Description = model.Description; // Berechnung der neuen Zeiten var day = DateTime.Parse(model.NewDate); var from = DateTime.Parse(model.NewBegin); var to = DateTime.Parse(model.NewEnd); var start = day.Add(from.TimeOfDay); var end = day.Add(to.TimeOfDay); // Das Änderungsobjekt anlegen var changeService = new ChangeService(Db); var changeObject = changeService.CreateActivityDateChange(activityDate, start, end, model.RoomIds); // Es hat keine Änderungen gegeben, die eine Notification ergeben! // es können sicht aber immer noch die Dozenten verändert haben // Das Umsetzen was geändert wurde activityDate.Hosts.Clear(); if (model.DozIds != null) { foreach (var dozId in model.DozIds) { activityDate.Hosts.Add(Db.Members.SingleOrDefault(m => m.Id == dozId)); } } if (changeObject != null) { // Es liegt eine Änderung vor => Änderung in DB speichern // Änderung umsetzen changeObject.UserId = AppUser.Id; Db.DateChanges.Add(changeObject); // Änderungen am DateObjekt vornehmen activityDate.Begin = start; activityDate.End = end; // es kommen die neuen Räume und Dozenten // => zuerst alle löschen! activityDate.Rooms.Clear(); if (model.RoomIds != null) { foreach (var roomId in model.RoomIds) { activityDate.Rooms.Add(Db.Rooms.SingleOrDefault(r => r.Id == roomId)); } } } // Um die Anzahl der Transaktionen klein zu halten werden erst // an dieser Stelle alle Änderungen am Datum und // dem ChangeObjekt gespeichert Db.SaveChanges(); // Jetzt erst die Notification auslösen if (changeObject != null) { NotificationService nservice = new NotificationService(); nservice.CreateSingleNotification(changeObject.Id.ToString()); } return(Json(new { result = "Redirect", url = Url.Action("Details", new { id = activityDate.Activity.Id }) })); }
public void SetPropertyValueWithNotification(object target, PropertyDescriptor descriptor, object value) { ChangeService.OnComponentChanging(target, descriptor); SetPropertyValue(target, descriptor, value); ChangeService.OnComponentChanged(target, descriptor, null, null); }
protected void OnComponentChanged() { ChangeService.OnComponentChanged(Control, null, null, null); }