public async Task <IActionResult> PutDataWeather(long id, DataWeather dataWeather) { if (id != dataWeather.Id) { return(BadRequest()); } _context.Entry(dataWeather).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DataWeatherExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <DataWeather> > PostDataWeather(DataWeather dataWeather) { _context.DataWeathers.Add(dataWeather); await _context.SaveChangesAsync(); return(CreatedAtAction("GetDataWeather", new { id = dataWeather.Id }, dataWeather)); }
public string[] GetRecomendations(DataWeather dw, string lang) { double[] skins = new double[] { 0, 1.4, 1.0, 0.7, 0.5 }; double[] uvis = new double[15] { 0, 0.42857, 0.85714, 1.28571, 1.71428, 2.1428, 2.5714, 3.0, 3.428, 3.857, 4.285, 4.714, 5.142, 5.571, 6.0 }; var currentuvi = uvis[dw.UVI ?? 1]; var timefirst = new double[5]; var timesecond = new double[5]; for (int i = 1; i < timefirst.Length; i++) { timefirst[i] = 0.4 / (currentuvi * skins[i]); timesecond[i] = 1 / (currentuvi * skins[i]); } if (lang == "1") { string sunbases = "Due to the UVI level recommended time for sunbasing is: < For 1st type of skin - " + HMS(timefirst[1]) + " minutes during first day of sunbasing per day, " + HMS(timesecond[1]) + " minutes during other days of sunbasing per day; <" + "For 2nd type of skin - " + HMS(timefirst[2]) + " minutes during first day of sunbasing per day, " + HMS(timesecond[2]) + " minutes during other days of sunbasing per day; <" + "For 3rd type of skin - " + HMS(timefirst[3]) + " minutes during first day of sunbasing per day, " + HMS(timesecond[3]) + " minutes during other days of sunbasing per day; <" + "For 4th type of skin - " + HMS(timefirst[4]) + " minutes during first day of sunbasing per day, " + HMS(timesecond[4]) + " minutes during other days of sunbasing per day; <"; string swim = "Taking into account the temperature of water, "; if (dw.WaterT < 14) { swim += "swimming is not recomended for non-tempered swimmers."; } else if (dw.WaterT < 18) { swim += "recommended time for swimming is 3-5 minutes"; } else if (dw.WaterT < 22) { swim += "recommended time for swimming is 10-12 minutes"; } else if (dw.WaterT < 24) { swim += "recommended time for swimming is 20-25 minutes"; } else { swim += "recommended time for swimming is not limited"; } string clothes = "According to temperature of the air, "; if (dw.AirT > 38) { clothes += "the weather is hot. Consider not going outside in order not to get sunstrike."; } else if (dw.AirT < 0) { clothes += "the weather is cold. Consider not going outside or put on the warmest clothes."; } else { clothes += "the weather is normal."; } string typeclothes = ""; if (dw.AirT > 38) { typeclothes = "1"; } else if (dw.AirT < 0) { typeclothes = "5"; } else { if (dw.AirT > 23 && dw.Wind < 6) { typeclothes = "1"; } else if (dw.AirT > 23 && dw.Wind > 6) { typeclothes = "2"; clothes += " The wind is strong. Some additional clothes are recommended."; } else if (dw.AirT > 15 && dw.Wind < 6) { typeclothes = "2"; } else if (dw.AirT > 15 && dw.Wind > 6) { typeclothes = "3"; clothes += " The wind is strong. Some additional clothes are recommended."; } else if (dw.AirT > 8) { typeclothes = "3"; } else { typeclothes = "4"; } } switch (typeclothes) { case "1": clothes += " The recommended type of clothes are t-shirt, shorts, etc."; break; case "2": clothes += " The recommended type of clothes are light pullover, light trousers, etc."; break; case "3": clothes += " The recommended type of clothes are jacket, trousers, etc."; break; case "4": clothes += " The recommended type of clothes are warm jacket, jeans, etc."; break; case "5": clothes += " The recommended type of clothes are winter jacket, winter trousers, etc."; break; } string hum = "The humidity of the air is about " + dw.Humidity + "%."; if (dw.Humidity > 65) { hum += " The value is higher than normal one. It may cause allergic reactions, asthma ect."; } else if (dw.Humidity < 45) { hum += " The value is lower than normal one. It may cause drought, sore throat, breathing problems ect."; } else { hum += " The value is in normal range."; } string[] results = { clothes, typeclothes, sunbases, swim, hum }; return(results); } else { string sunbases = "Враховуючи індекс УФ випромінюваня рекомендованою тривалістю для загоряння: < Для першого типу шкіри - " + HMS(timefirst[1]) + " хвилин в перший день сонячних ванн, " + HMS(timesecond[1]) + " хвилин в день в інші дні загоряння; <" + "Для другого типу шкіри - " + HMS(timefirst[2]) + " хвилин в перший день сонячних ванн, " + HMS(timesecond[2]) + " хвилин в день в інші дні загоряння; <" + "Для третього типу шкіри - " + HMS(timefirst[3]) + " хвилин в перший день сонячних ванн, " + HMS(timesecond[3]) + " хвилин в день в інші дні загоряння; <" + "Для четвертого типу шкіри - " + HMS(timefirst[4]) + " хвилин в перший день сонячних ванн, " + HMS(timesecond[4]) + " хвилин в день в інші дні загоряння; <"; string swim = "Враховуючи температуру води, "; if (dw.WaterT < 14) { swim += "плавання не рекомендується для непідготовлених людей."; } else if (dw.WaterT < 18) { swim += "рекомендований час для плавання складає 3-5 хвилин"; } else if (dw.WaterT < 22) { swim += "рекомендований час для плавання складає 10-12 хвилин"; } else if (dw.WaterT < 24) { swim += "рекомендований час для плавання складає 15-25 хвилин"; } else { swim += "рекомендований час для плавання не обмежений"; } string clothes = "Враховуючи температуру повітря, "; if (dw.AirT > 38) { clothes += "погода дуже жарка. Не рекомендується довге перебування на відкритому повітрі задля попередження теплових ударів."; } else if (dw.AirT < 0) { clothes += "погода досить холодна. Рекомендується не виходити на вулицю на великі проміжки часу або рекомендований теплий одяг."; } else { clothes += "погода доволі комфортна."; } string typeclothes = ""; if (dw.AirT > 38) { typeclothes = "1"; } else if (dw.AirT < 0) { typeclothes = "5"; } else { if (dw.AirT > 23 && dw.Wind < 6) { typeclothes = "1"; } else if (dw.AirT > 23 && dw.Wind > 6) { typeclothes = "2"; clothes += " Вітер дуже сильний. Рекомендований додатковий одяг для попередження протягів."; } else if (dw.AirT > 15 && dw.Wind < 6) { typeclothes = "2"; } else if (dw.AirT > 15 && dw.Wind > 6) { typeclothes = "3"; clothes += " Вітер дуже сильний. Рекомендований додатковий одяг для попередження протягів."; } else if (dw.AirT > 8) { typeclothes = "3"; } else { typeclothes = "4"; } } switch (typeclothes) { case "1": clothes += " Рекомендований тип одягу - футболки, блузки, шорти, ітд."; break; case "2": clothes += " Рекомендований тип одягу - легкі кофти, легкі штани, ітд."; break; case "3": clothes += " Рекомендований тип одягу - піджак, штаниs, ітд."; break; case "4": clothes += " Рекомендований тип одягу - тепла куртка, джинси, ітд."; break; case "5": clothes += " Рекомендований тип одягу - зимня куртка, теплі штани, ітд."; break; } string hum = "Вологість повітря складає " + dw.Humidity + "%."; if (dw.Humidity > 65) { hum += " Значення вище норми. Це може спричинити алергічні реакції, астму, ітд."; } else if (dw.Humidity < 45) { hum += " Значення нижче норми. Це може спричинити засушливість, ангіну, проблеми з диханням, ітд."; } else { hum += " Значення у межах норми."; } string[] results = { clothes, typeclothes, sunbases, swim, hum }; return(results); } }