/// <summary> /// Constructeur /// </summary> public CoordsManager() { InitializeComponent(); _Service = new CoordsService(); _Opacity = new ImageAttributes(); _TransparentFillBrush = FormsTools.GetMasksFillingColors()[0]; //Timer _FrequencyTimer = new Timer(); _FrequencyTimer.Tick += new EventHandler(CallBack_Frequency); _FrequencyTimer.Interval = 200; }
public async Task <IActionResult> Post(string tripName, [FromBody] StopViewModel vm) { try { if (ModelState.IsValid) { var newStop = Mapper.Map <Stop>(vm); var result = await CoordsService.GetCoordsAsync(newStop.Name); if (!result.Success) { Logger.LogError(result.Message); } else { newStop.Latitude = result.Latitude; newStop.Longitude = result.Longitude; Repository.AddStop(tripName, newStop, User.Identity.Name); if (await Repository.SaveChangesAsync()) { return(Created($"/api/trips/{tripName}/stops/{newStop.Name}", Mapper.Map <StopViewModel>(newStop))); } } } } catch (Exception ex) { Logger.LogError("Failed to save a new Stop: {0}", ex); } return(BadRequest("Failed to save new stop")); }
public StopController(IWorldRepository repository, ILogger <StopController> logger, CoordsService coordService) { _repository = repository; _logger = logger; _coordService = coordService; }