public void SaveHistoryCrawl(WeatherForecaster obj) { try { _context.ViewWeatherHistoryCrawl.Add(new ViewWeatherHistoryCrawl { City = obj.Address, CreatedDate = DateTime.UtcNow, IpAddress = Common.CommonHelper.getIpAccess(), Temperature = obj.TemperatureC + " __ " + obj.TemperatureF, }); _context.SaveChanges(); } catch (Exception ex) { throw ex; } }
public async Task <bool> SendDBTT(MessengerMessaging mes) { var weather = await _weatherService.GetWeatherFromCity(CommonHelper.ConvertUtf8ConvertNotReplcae(mes.Message.Text)); if (weather != null) { var response = new MessengerMessage { Text = $"DBTT {DateTime.UtcNow.ToString("dd.MM.yyyy")}, tại {weather.name} NĐ là: {weather.main.temp}, NĐ cao nhất: {weather.main.temp_max}, thấp nhất: {weather.main.temp_max} có {weather.weather[0].description} <3 From Khoapiterrr with love" }; _ = messageSender.SendAsync(response, new MessengerUser { Id = mes.Sender.Id }); try { var Sender = await _messengerProfile.GetUserProfileAsync(mes.Sender.Id); _context.ViewWeatherHistoryApi.Add(new Entity.ViewWeatherHistoryApi { City = weather.name, CreatedDate = DateTime.UtcNow, FacebookId = mes.Sender.Id, Name = Sender.Result.FirstName + " " + Sender.Result.LastName, Temperature = weather.main.temp.ToString() }); _context.SaveChanges(); } catch (Exception ex) { throw ex; } return(true); } _ = messageSender.SendAsync(new MessengerMessage { Text = "Xin lỗi bạn, mình không tìm thấy thành phố của bạn. Vui lòng gõ chính xác" }, new MessengerUser { Id = mes.Sender.Id }); return(false); }