public void unexpected_exception_causes_internal_server_error_problem() { Given(() => an_(unexpected_exception)); When(handling_a_request); Then(it_is_an_internal_error); And(() => it_logs(AlertFactory.UnknownErrorOccured(services.GetRequiredService <IMonitorServices>().Info, unexpected_exception))); }
public async Task <IActionResult> Edit(Guid id, [Bind("Id, FirstName, LastName, BirthDate, Gender, ProfileId, CountryId")] VisitorViewModel vm) { if (ModelState.IsValid) { var getOperation = await _bo.ReadAsync((Guid)id); if (!getOperation.Success) { return(OperationErrorBackToIndex(getOperation.Exception)); } if (getOperation.Result == null) { return(RecordNotFound()); } var result = getOperation.Result; result.FirstName = vm.FirstName; result.LastName = vm.LastName; result.BirthDate = vm.BirthDate; result.Gender = vm.Gender; result.ProfileId = vm.ProfileId; result.CountryId = vm.CountryId; var updateOperation = await _bo.UpdateAsync(result); if (!updateOperation.Success) { TempData["Alert"] = AlertFactory.GenerateAlert(NotificationType.Danger, updateOperation.Exception); return(View(vm)); } else { return(OperationSuccess("The record was successfuly updated")); } } return(RedirectToAction(nameof(Index))); }
internal static IApplicationBuilder MapExceptionsToProblems(this IApplicationBuilder app) { app.UseExceptionHandler(error => error.Run(context => { var feature = context.Features.Get <IExceptionHandlerFeature>(); var exceptionHandler = app.ApplicationServices.GetRequiredService <ExceptionHandler>(); var(statusCode, problem) = exceptionHandler.HandleException(feature.Error); context.Response.StatusCode = (int)statusCode; if (statusCode == HttpStatusCode.InternalServerError) { Log.Logger.Error(AlertFactory.UnknownErrorOccured(app.ApplicationServices.GetRequiredService <IMonitorServices>().Info, feature.Error).Serialize()); } if (problem == Problem.Empty) { return(context.Response.CompleteAsync()); } context.Response.ContentType = MediaType.JsonProblem; return(context.Response.WriteAsync(problem.Serialize())); })); return(app); }
public async Task <IActionResult> Edit(Guid id, TitleViewModel vm) { if (ModelState.IsValid) { var getOperation = await _bo.ReadAsync(id); if (!getOperation.Success) { return(OperationErrorBackToIndex(getOperation.Exception)); } if (getOperation.Result == null) { return(RecordNotFound()); } var result = getOperation.Result; if (!vm.CompareToModel(result)) { result = vm.ToModel(result); var updateOperation = await _bo.UpdateAsync(result); if (!updateOperation.Success) { TempData["Alert"] = AlertFactory.GenerateAlert(NotificationType.Danger, updateOperation.Exception); return(View(vm)); } else { return(OperationSuccess("The record was successfuly updated")); } } } return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Create(BrandViewModel vm) { if (ModelState.IsValid) { var model = vm.ToModel(); var createOperation = await _bo.CreateAsync(model); if (!createOperation.Success) { return(OperationErrorBackToIndex(createOperation.Exception)); } if (!createOperation.Result) { TempData["Alert"] = AlertFactory.GenerateAlert(NotificationType.Danger, createOperation.Message); Draw("Create", "fa-plus"); return(View()); } else { return(OperationSuccess("The record was successfuly created")); } } return(View(vm)); }
public void a_set_of_available_and_unavailable_instances_alerts_those_that_are_down() { Given(available_instance); And(() => unavailable_instance(unavailable_alert)); When(getting_availability); Then(() => alerts(AlertFactory.InstanceUnavailable(unavailable_alert.Monitor, unavailable_alert.Message))); }
public async Task <IActionResult> Edit(Guid id, [Bind("Id, Description, Stars, Date, InterestPointId, VisitorId")] FeedbackViewModel vm) { if (ModelState.IsValid) { var getOperation = await _bo.ReadAsync((Guid)id); if (!getOperation.Success) { return(OperationErrorBackToIndex(getOperation.Exception)); } if (getOperation.Result == null) { return(NotFound()); } var result = getOperation.Result; result.Description = vm.Description; result.Stars = vm.Stars; result.Date = vm.Date; result.InterestPointId = vm.InterestPointId; result.VisitorId = vm.VisitorId; var updateOperation = await _bo.UpdateAsync(result); if (!updateOperation.Success) { TempData["Alert"] = AlertFactory.GenerateAlert(NotificationType.Danger, updateOperation.Exception); return(View(vm)); } else { return(OperationSuccess("The record was successfuly updated")); } } return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Edit(Guid id, [Bind("Id,Description, PhotoPath")] ProfileViewModel vm) { if (ModelState.IsValid) { var getOperation = await _bo.ReadAsync((Guid)id); if (!getOperation.Success) { return(OperationErrorBackToIndex(getOperation.Exception)); } if (getOperation.Result == null) { return(RecordNotFound()); } var result = getOperation.Result; result.Description = vm.Description; result.PhotoPath = vm.PhotoPath; var updateOperation = await _bo.UpdateAsync(result); if (!updateOperation.Success) { TempData["Alert"] = AlertFactory.GenerateAlert(NotificationType.Danger, updateOperation.Exception); return(View(vm)); } else { return(OperationSuccess("The record was successfuly updated")); } } return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Create(RegionViewModel vm) { if (ModelState.IsValid) { var model = vm.ToModel(); var createOperation = await _bo.CreateAsync(model); if (!createOperation.Success) { return(OperationErrorBackToIndex(createOperation.Exception)); } if (!createOperation.Result) { TempData["Alert"] = AlertFactory.GenerateAlert(NotificationType.Danger, createOperation.Message); ViewData["Title"] = "Create Region"; var crumbs = GetCrumbs(); crumbs.Add(new BreadCrumb() { Action = "Create", Controller = "Regions", Icon = "fa-search", Text = "Create" }); ViewData["BreadCrumbs"] = crumbs; return(View(vm)); } return(OperationSuccess("The record was successfuly created")); } return(View(vm)); }
public async Task <IActionResult> Create(ReservedQueueViewModel vm) { if (ModelState.IsValid) { var model = vm.ToReservedQueue(); var createOperation = await _bo.CreateAsync(model); if (!createOperation.Success) { return(OperationErrorBackToIndex(createOperation.Exception)); } if (!createOperation.Result) { TempData["Alert"] = AlertFactory.GenerateAlert(NotificationType.Danger, createOperation.Message); var listEstOperation = await _ebo.ListNotDeletedAsync(); if (!listEstOperation.Success) { return(OperationErrorBackToIndex(listEstOperation.Exception)); } var listProOperation = await _pbo.ListNotDeletedAsync(); if (!listProOperation.Success) { return(OperationErrorBackToIndex(listProOperation.Exception)); } var estList = new List <SelectListItem>(); foreach (var item in listEstOperation.Result) { estList.Add(new SelectListItem() { Value = item.Id.ToString(), Text = item.Address }); } var profiList = new List <SelectListItem>(); foreach (var item in listProOperation.Result) { profiList.Add(new SelectListItem() { Value = item.Id.ToString(), Text = item.VatNumber.ToString() }); } ViewBag.Establishments = estList; ViewBag.Profiles = profiList; Draw("Create", "fa-plus"); return(View(vm)); } else { return(OperationSuccess("The record was successfuly created")); } } return(View(vm)); }
public async Task <IActionResult> Edit(Guid id, ShoppingBasketViewModel vm) { var listROperation = await _pbo.ListNotDeletedAsync(); if (!listROperation.Success) { return(OperationErrorBackToIndex(listROperation.Exception)); } var pList = new List <SelectListItem>(); foreach (var item in listROperation.Result) { var listItem = new SelectListItem() { Value = item.Id.ToString(), Text = item.VatNumber.ToString() }; if (item.Id == vm.ProfileId) { listItem.Selected = true; } pList.Add(listItem); } ViewBag.Regions = pList; Draw("Edit", "fa-edit"); if (ModelState.IsValid) { var getOperation = await _bo.ReadAsync(id); if (!getOperation.Success) { return(OperationErrorBackToIndex(getOperation.Exception)); } if (getOperation.Result == null) { return(RecordNotFound()); } var result = getOperation.Result; if (!vm.CompareToModel(result)) { result = vm.ToModel(result); var updateOperation = await _bo.UpdateAsync(result); if (!updateOperation.Success) { TempData["Alert"] = AlertFactory.GenerateAlert(NotificationType.Danger, updateOperation.Exception); return(View(vm)); } else { return(OperationSuccess("The record was successfuly updated")); } } } return(RedirectToAction(nameof(Index))); }
private void dependency_1_has_lost_redundancy() { var availability = Availability.Up(); availability.Add(AlertFactory.ServiceRedundancyLost(Fake.AnInstanceMonitor.Info, "Ooops")); service_dependency_1.Monitor.Availability().Returns(availability); service_dependencies.Add(service_dependency_1); }
private void dependency_1_has_instance_unavailability() { service_dependency_1.Monitor.Availability().Returns( Availability.Up() | Availability.Up() | Availability.Down(AlertFactory.InstanceUnavailable(Fake.AnInstanceMonitor.Info, "Ooops")) ); service_dependencies.Add(service_dependency_1); }
public void a_set_with_a_single_available_instance_alerts_redundancy_loss() { Given(available_instance); And(() => unavailable_instance(unavailable_alert)); When(getting_availability); Then(() => alerts( AlertFactory.ServiceRedundancyLost(multi_instance_monitor.Info, "Redundancy has been lost."))); }
public async Task <IActionResult> Info(ONGViewModel ongViewModel) { await _ongAppService.Update(ongViewModel); TempData[TempDataConstants.ShowAlert] = AlertFactory.ONGUpdated(); return(RedirectToAction("Index")); }
public AlertMgr(string currentSticker) { CurrentSticker = currentSticker; GetQuoteAndStdIndicator(); Factory = new AlertFactory(StdDevResults, HistoricalQuotes); CurrentQuote = HistoricalQuotes.OrderByDescending(q => q.Date).FirstOrDefault(); RsiResults = new List <StochResult>(); ChaikinOscResults = new List <ChaikinOscResult>(); }
public async Task <IActionResult> Create(MenuViewModel vm) { var listMealOperation = await _mbo.ListNonDeletedAsync(); if (!listMealOperation.Success) { return(OperationErrorBackToIndex(listMealOperation.Exception)); } var listRestOperation = await _rbo.ListNonDeletedAsync(); if (!listRestOperation.Success) { return(OperationErrorBackToIndex(listRestOperation.Exception)); } var mealList = new List <SelectListItem>(); foreach (var item in listMealOperation.Result) { mealList.Add(new SelectListItem() { Value = item.Id.ToString(), Text = item.Name }); } var restList = new List <SelectListItem>(); foreach (var item in listRestOperation.Result) { restList.Add(new SelectListItem() { Value = item.Id.ToString(), Text = item.Name }); } ViewBag.Meals = mealList; ViewBag.Restaurants = restList; if (ModelState.IsValid) { var model = vm.ToModel(); var createOperation = await _bo.CreateAsync(model); if (!createOperation.Success) { TempData["Alert"] = AlertFactory.GenerateAlert(NotificationType.Danger, createOperation.Exception); return(View(vm)); } else { return(OperationSuccess("The record was successfuly created")); } } return(View(vm)); }
public void a_set_of_unavailable_instances_alerts_that_all_instances_are_down() { Given(() => unavailable_instance(unavailable_alert)); And(() => unavailable_instance(unavailable_alert_2)); When(getting_availability); Then(() => alerts(AlertFactory.ServiceUnavailable(new MonitorInfo(unavailable_alert.Monitor.Type, unavailable_alert.Monitor.Name, unavailable_alert.Monitor.Instances.Concat(unavailable_alert_2.Monitor.Instances).ToArray()), unavailable_alert.Message))); }
public override Availability Availability() { try { Db.ExecuteAsync("SELECT 1", commandType: CommandType.Text).GetAwaiter().GetResult(); return(Monitoring.Availability.Up()); } catch (Exception ex) { return(Monitoring.Availability.Down(AlertFactory.ServiceUnavailable(Info, $"Database is down: {ex.Message}"))); } }
public override Availability Availability() { try { CheckConnectivity(); return(Monitoring.Availability.Up()); } catch { return(Monitoring.Availability.Down(AlertFactory.ServiceUnavailable(Info, "Cosmos is unavailable or not configured."))); } }
public override Availability Availability() { try { return(url.WithHeaders(headers).GetAsync().Result.IsSuccessStatusCode ? Sensemaking.Monitoring.Availability.Up() : Sensemaking.Monitoring.Availability.Down(AlertFactory.ServiceUnavailable(Info, $"Service at {url} is down."))); } catch { return(Sensemaking.Monitoring.Availability.Down(AlertFactory.ServiceUnavailable(Info, $"Service at {url} is down."))); } }
public async Task <IActionResult> Register(RegisterViewModel vm) { var accountBo = new AccountBusinessController(UserManager, RoleManager); var profile = new Profile(vm.VatNumber, vm.FirstName, vm.LastName, vm.PhoneNumber, vm.BirthDate); var registerOperation = await accountBo.Register(vm.UserName, vm.Email, vm.Password, profile, vm.Role); if (registerOperation.Success) { return(OperationSuccess("The account was successfuly registered!")); } TempData["Alert"] = AlertFactory.GenerateAlert(NotificationType.Danger, registerOperation.Message); return(View(vm)); }
public async Task <IActionResult> Login(LoginViewModel vm) { var loginOperation = await SignInManager.PasswordSignInAsync(vm.UserName, vm.Password, false, false); if (loginOperation.Succeeded) { return(OperationSuccess("Welcome User")); } else { TempData["Alert"] = AlertFactory.GenerateAlert(NotificationType.Danger, loginOperation.ToString()); return(View(vm)); } }
private void AlertListView_ItemTapped(object sender, ItemTappedEventArgs e) { if (((AlertItem)e.Item).alertMessage.Contains("Power has dropped!")) { AlertFactory.GetSingleton().CreateAlert(((AlertItem)e.Item).alertMessage); } if (((AlertItem)e.Item).alertMessage.Contains("Cadence has dropped!")) { AlertFactory.GetSingleton().CreateAlert(((AlertItem)e.Item).alertMessage); } if (((AlertItem)e.Item).alertMessage.Contains("Speed has dropped!")) { AlertFactory.GetSingleton().CreateAlert(((AlertItem)e.Item).alertMessage); } }
public async Task <IActionResult> New(DishViewModel vm) { if (ModelState.IsValid) { var model = vm.ToModel(); var createOperation = await _bo.CreateAsync(model); if (!createOperation.Success) { TempData["Alert"] = AlertFactory.GenerateAlert(NotificationType.Danger, createOperation.Exception); return(View(vm)); } else { return(OperationSuccess("The record was successfuly created")); } } return(View(vm)); }
public async void Should_Fill_Alerts_Table() { var msgL = await _mtaFeedService.GetCurrentRealtimeFeedMessage(SubwayLines.L); var msgIrt = await _mtaFeedService.GetCurrentRealtimeFeedMessage(SubwayLines.RED_GREEN_S); var alertFactory = new AlertFactory(); var alertsIrt = alertFactory.CreateItemsFromFeedMessage(msgIrt); var alertsL = alertFactory.CreateItemsFromFeedMessage(msgL); // Clear Tables using (var alertRepos = new AlertRepository() { Connection = _connection }) { alertRepos.ClearAll(); // Load Tables alertRepos.AddRange(alertsIrt); alertRepos.AddRange(alertsL); } }
public async Task <IActionResult> Upsert(ONGViewModel ongViewModel) { if (!ModelState.IsValid) { return(View(ongViewModel)); } if (ongViewModel.Id == Guid.Empty) { await _ongAppService.Create(ongViewModel); } else { await _ongAppService.Update(ongViewModel); } TempData[TempDataConstants.ShowAlert] = AlertFactory.NewONGCreated(); return(RedirectToAction("Index")); }
public async Task <IActionResult> Edit(Guid id, [Bind("Id, Name, Description, Address, PhotoPath, OpeningHours, " + "ClosingHours, ClosingDays, CovidSafe, Status, CompanyId")] InterestPointViewModel vm) { if (ModelState.IsValid) { var getOperation = await _bo.ReadAsync((Guid)id); if (!getOperation.Success) { return(OperationErrorBackToIndex(getOperation.Exception)); } if (getOperation.Result == null) { return(RecordNotFound()); } var result = getOperation.Result; result.Name = vm.Name; result.Description = vm.Description; result.Address = vm.Address; result.PhotoPath = vm.PhotoPath; result.OpeningHours = vm.OpeningHours; result.ClosingHours = vm.ClosingHours; result.ClosingDays = vm.ClosingDays; result.CovidSafe = vm.CovidSafe; result.Status = vm.Status; result.CompanyId = vm.CompanyId; var updateOperation = await _bo.UpdateAsync(result); if (!updateOperation.Success) { TempData["Alert"] = AlertFactory.GenerateAlert(NotificationType.Danger, updateOperation.Exception); return(View(vm)); } else { return(OperationSuccess("The record was successfuly updated")); } } return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Review([FromRoute] Guid id, bool approved) { var ong = await _ongAppService.Find(id); ong.Approved = approved ? "Sim" : "Não"; await _ongAppService.Update(ong); if (approved) { var user = await _userAppService.CreateONGUser(ong.ResponsibleEmail); await _ongAppService.UpdateUserId(ong, Guid.Parse(user.User.Id)); await _emailSender.SendEmailAsync(ong.ResponsibleEmail, ong.Name, $@"<p>Nova senha: {user.TempPassword} <br /> Será alterada no primeiro logi.</p>"); } TempData[TempDataConstants.ShowAlert] = approved ? AlertFactory.NewONGApproved() : AlertFactory.NewONGReproved(); return(RedirectToAction("Index", new { area = "Admin" })); }
public async Task <IActionResult> Upsert(RequestViewModel requestViewModel, Guid?id) { if (!ModelState.IsValid) { return(View(requestViewModel)); } if (!id.HasValue || id.Value == Guid.Empty) { await _ongAppService.CreateRequest(requestViewModel); TempData[TempDataConstants.ShowAlert] = AlertFactory.NewRequestCreated(); } else { await _ongAppService.UpdateRequest(requestViewModel); TempData[TempDataConstants.ShowAlert] = AlertFactory.RequestEdited(); } return(RedirectToAction("Index", new { area = "ONG" })); }
public async Task <IActionResult> Register(RegisterViewModel vm) { var accountBo = new AccountBusinessController(UserManager, RoleManager); var person = new Profile(vm.Description, vm.PhotoPath); var registerOperation = await accountBo.Register(vm.UserName, vm.Email, vm.Password, person, vm.Role); if (registerOperation.Success) { if (vm.Role == "Visitor") { return(RedirectToAction("Create", "Visitors")); } if (vm.Role == "Company") { return(RedirectToAction("Create", "Companies")); } } //return OperationSuccess("The account was successfuly registered!"); TempData["Alert"] = AlertFactory.GenerateAlert(NotificationType.Danger, registerOperation.Message); return(View(vm)); }
private static async Task AsyncMain() { // Load Feed Message var dbConnStr = ConfigurationManager.ConnectionStrings["DbConnStr"].ConnectionString; var combinedUrl = string.Format(Url, ApiKey); var service = new FeedMessageService(combinedUrl); var msgIrt = await service.GetCurrentRealtimeFeedMessage(SubwayLines.RED_GREEN_S); var msgL = await service.GetCurrentRealtimeFeedMessage(SubwayLines.L); var alertFactory = new AlertFactory(); var stopTimeFactory = new StopTimeUpdateFactory(); var tripFactory = new TripFactory(); var vehicleFactory = new VehiclePositionFactory(); var alertsIrt = alertFactory.CreateItemsFromFeedMessage(msgIrt); var alertsL = alertFactory.CreateItemsFromFeedMessage(msgL); using (SqlConnection conn = new SqlConnection(dbConnStr)) { using (var alertRepos = new AlertRepository() {Connection = conn}) { // Clear Tables alertRepos.ClearAll(); // Load Tables alertRepos.AddRange(alertsIrt); alertRepos.AddRange(alertsL); } var stopsIrt = stopTimeFactory.CreateItemsFromFeedMessage(msgIrt); var stopsL = stopTimeFactory.CreateItemsFromFeedMessage(msgL); using (var stopsRepos = new StopTimeUpdateRepository() { Connection = conn }) { // Clear Tables stopsRepos.ClearAll(); // Load Tables stopsRepos.AddRange(stopsIrt); stopsRepos.AddRange(stopsL); } var tripsIrt = tripFactory.CreateItemsFromFeedMessage(msgIrt); var tripsL = tripFactory.CreateItemsFromFeedMessage(msgL); using (var tripsRepos = new TripRepository() { Connection = conn }) { // Clear Tables tripsRepos.ClearAll(); // Load Tables tripsRepos.AddRange(tripsIrt); tripsRepos.AddRange(tripsL); } var vehiclesIrt = vehicleFactory.CreateItemsFromFeedMessage(msgIrt); var vehiclesL = vehicleFactory.CreateItemsFromFeedMessage(msgL); using (var vehiclesRepos = new VehiclePositionRepository() { Connection = conn }) { // Clear Tables vehiclesRepos.ClearAll(); // Load Tables vehiclesRepos.AddRange(vehiclesIrt); vehiclesRepos.AddRange(vehiclesL); } } }
public async void Should_Fill_All_Tables() { var msgL = await _mtaFeedService.GetCurrentRealtimeFeedMessage(SubwayLines.L); var msgIrt = await _mtaFeedService.GetCurrentRealtimeFeedMessage(SubwayLines.RED_GREEN_S); var alertFactory = new AlertFactory(); var stopTimeFactory = new StopTimeUpdateFactory(); var tripFactory = new TripFactory(); var vehicleFactory = new VehiclePositionFactory(); var alertsIrt = alertFactory.CreateItemsFromFeedMessage(msgIrt); var alertsL = alertFactory.CreateItemsFromFeedMessage(msgL); using (var alertRepos = new AlertRepository() { Connection = _connection }) { // Clear Tables alertRepos.ClearAll(); // Load Tables alertRepos.AddRange(alertsIrt); alertRepos.AddRange(alertsL); } var stopsIrt = stopTimeFactory.CreateItemsFromFeedMessage(msgIrt); var stopsL = stopTimeFactory.CreateItemsFromFeedMessage(msgL); using (var stopsRepos = new StopTimeUpdateRepository() { Connection = _connection }) { // Clear Tables stopsRepos.ClearAll(); // Load Tables stopsRepos.AddRange(stopsIrt); stopsRepos.AddRange(stopsL); } var tripsIrt = tripFactory.CreateItemsFromFeedMessage(msgIrt); var tripsL = tripFactory.CreateItemsFromFeedMessage(msgL); using (var tripsRepos = new TripRepository() { Connection = _connection }) { // Clear Tables tripsRepos.ClearAll(); // Load Tables tripsRepos.AddRange(tripsIrt); tripsRepos.AddRange(tripsL); } var vehiclesIrt = vehicleFactory.CreateItemsFromFeedMessage(msgIrt); var vehiclesL = vehicleFactory.CreateItemsFromFeedMessage(msgL); using (var vehiclesRepos = new VehiclePositionRepository() { Connection = _connection }) { // Clear Tables vehiclesRepos.ClearAll(); // Load Tables vehiclesRepos.AddRange(vehiclesIrt); vehiclesRepos.AddRange(vehiclesL); } }
/// <summary> /// When implemented in a derived class, executes the scheduled job asynchronously. Implementations that want to know whether /// the scheduled job is being cancelled can get a <see cref="P:Microsoft.WindowsAzure.Mobile.Service.ScheduledJob.CancellationToken"/> from the <see cref="M:CancellationToken"/> property. /// </summary> /// <returns> /// A <see cref="T:System.Threading.Tasks.Task"/> representing the asynchronous operation. /// </returns> public override async Task ExecuteAsync() { // Load Feed Message var dbConnStr = ConfigurationManager.ConnectionStrings["MTA_DB"].ConnectionString; var combinedUrl = string.Format(Url, ApiKey); var service = new FeedMessageService(combinedUrl); var msgIrt = await service.GetCurrentRealtimeFeedMessage(SubwayLines.RED_GREEN_S); var msgL = await service.GetCurrentRealtimeFeedMessage(SubwayLines.L); var alertFactory = new AlertFactory(); var stopTimeFactory = new StopTimeUpdateFactory(); var tripFactory = new TripFactory(); var vehicleFactory = new VehiclePositionFactory(); var alertsIrt = alertFactory.CreateItemsFromFeedMessage(msgIrt); var alertsL = alertFactory.CreateItemsFromFeedMessage(msgL); using (SqlConnection conn = new SqlConnection(dbConnStr)) { conn.Open(); using (var alertRepos = new AlertRepository() {Connection = conn}) { // Clear Tables alertRepos.ClearAll(); // Load Tables alertRepos.AddRange(alertsIrt); alertRepos.AddRange(alertsL); } var stopsIrt = stopTimeFactory.CreateItemsFromFeedMessage(msgIrt); var stopsL = stopTimeFactory.CreateItemsFromFeedMessage(msgL); using (var stopsRepos = new StopTimeUpdateRepository() { Connection = conn }) { // Clear Tables stopsRepos.ClearAll(); // Load Tables stopsRepos.AddRange(stopsIrt); stopsRepos.AddRange(stopsL); } var tripsIrt = tripFactory.CreateItemsFromFeedMessage(msgIrt); var tripsL = tripFactory.CreateItemsFromFeedMessage(msgL); using (var tripsRepos = new TripRepository() { Connection = conn }) { // Clear Tables tripsRepos.ClearAll(); // Load Tables tripsRepos.AddRange(tripsIrt); tripsRepos.AddRange(tripsL); } var vehiclesIrt = vehicleFactory.CreateItemsFromFeedMessage(msgIrt); var vehiclesL = vehicleFactory.CreateItemsFromFeedMessage(msgL); using (var vehiclesRepos = new VehiclePositionRepository() { Connection = conn }) { // Clear Tables vehiclesRepos.ClearAll(); // Load Tables vehiclesRepos.AddRange(vehiclesIrt); vehiclesRepos.AddRange(vehiclesL); } using (var cmd = new SqlCommand("sp_CreateRealtimeSchedule", conn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.ExecuteNonQuery(); } } //return Task.FromResult(true); }