// GET: Pollutants/Delete/5 public async Task <IActionResult> Delete(int?id, string SortOrder, string NameKKFilter, string NameRUFilter, string NameENFilter, int?PageSize, int?PageNumber) { ViewBag.SortOrder = SortOrder; ViewBag.PageSize = PageSize; ViewBag.PageNumber = PageNumber; ViewBag.NameKKFilter = NameKKFilter; ViewBag.NameRUFilter = NameRUFilter; ViewBag.NameENFilter = NameENFilter; if (id == null) { return(NotFound()); } Pollutant pollutant = null; HttpResponseMessage response = await _HttpApiClient.GetAsync($"api/Pollutants/{id.ToString()}"); if (response.IsSuccessStatusCode) { pollutant = await response.Content.ReadAsAsync <Pollutant>(); } if (pollutant == null) { return(NotFound()); } return(View(pollutant)); }
public async Task <ActionResult <Pollutant> > PostPollutant(Pollutant pollutant) { _context.Pollutant.Add(pollutant); await _context.SaveChangesAsync(); return(CreatedAtAction("GetPollutant", new { id = pollutant.Id }, pollutant)); }
public async Task <IActionResult> PutPollutant(int id, Pollutant pollutant) { if (id != pollutant.Id) { return(BadRequest()); } _context.Entry(pollutant).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PollutantExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public Sources(string userPolluName, Pollutant userPolluType, Active multipleSources, Active activeChem) { UserPolluName = userPolluName; UserPolluType = (int)userPolluType; UserPartDiameter = 10.0; UserPartDensity = 1.0; MultipleSources = (int)multipleSources; ActiveChem = (int)activeChem; }
public async Task <IActionResult> Edit(int id, [Bind("Id,NameKK,NameRU,NameEN")] Pollutant pollutant, string SortOrder, string NameKKFilter, string NameRUFilter, string NameENFilter, int?PageSize, int?PageNumber) { ViewBag.SortOrder = SortOrder; ViewBag.PageSize = PageSize; ViewBag.PageNumber = PageNumber; ViewBag.NameKKFilter = NameKKFilter; ViewBag.NameRUFilter = NameRUFilter; ViewBag.NameENFilter = NameENFilter; if (id != pollutant.Id) { return(NotFound()); } if (ModelState.IsValid) { HttpResponseMessage response = await _HttpApiClient.PutAsJsonAsync( $"api/Pollutants/{pollutant.Id}", pollutant); string OutputViewText = await response.Content.ReadAsStringAsync(); OutputViewText = OutputViewText.Replace("<br>", Environment.NewLine); try { response.EnsureSuccessStatusCode(); } catch { dynamic errors = JsonConvert.DeserializeObject <dynamic>(OutputViewText); foreach (Newtonsoft.Json.Linq.JProperty property in errors.Children()) { ModelState.AddModelError(property.Name, property.Value[0].ToString()); } return(View(pollutant)); } pollutant = await response.Content.ReadAsAsync <Pollutant>(); return(RedirectToAction(nameof(Index), new { SortOrder = ViewBag.SortOrder, PageSize = ViewBag.PageSize, PageNumber = ViewBag.PageNumber, NameKKFilter = ViewBag.NameKKFilter, NameRUFilter = ViewBag.NameRUFilter, NameENFilter = ViewBag.NameENFilter })); } return(View(pollutant)); }
public override int GetHashCode() { unchecked { var hashCode = (Name != null ? Name.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Pollutant != null ? Pollutant.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Limit.GetHashCode(); hashCode = (hashCode * 397) ^ Percent.GetHashCode(); hashCode = (hashCode * 397) ^ Id; return(hashCode); } }
/// <summary> /// Returns the result of the reaction between the Microorganism and the Pollutant, by how much a Microorganism's energy is incremented or decremented /// </summary> /// <param name="microorganism">The Microorganism name</param> /// <param name="pollutant">The Pollutant name</param> /// <returns>The amount of change in the microorganism's energy per tick</returns> public static float GetReaction(Microorganism microorganism, Pollutant pollutant) { Consumption consumption = new Consumption(microorganism, pollutant); if (reactionTable.Keys.Any(x => x == consumption)) { return(reactionTable[new Consumption(microorganism, pollutant)]); } else { return(0); } }
public void MainActivity() { try { Place objPlace = new Place(); List <RecordsModel> objRecordsModel = new List <RecordsModel>(); List <RecordsModel> objCityList = new List <RecordsModel>(); //fetching country, state, city name from govt api objRecordsModel = objPlace.FetchPlace(); //adding country, state, city name from govt api to database objPlace.AddPlace(objRecordsModel); //fetching city details from database(above list may keep changing so we are taking city details from database) objCityList = objPlace.FetchCity(); //fetching station records from pvt api based on the city foreach (var cityRecord in objCityList) { Place objPlace1 = new Place(); List <StationModel> objStationList = new List <StationModel>(); string cityId = cityRecord.id; string city = cityRecord.city; ////for debugger point //string str = ""; //on the basis of city we call below function and get the station list with aqi,name & lat long from pvt api objStationList = objPlace1.FetchStation(city); //add station name,aqi, lat long into the database objPlace1.addStation(objStationList, cityId); if (objStationList != null) { //fetch and add pollutants of stations of every city. Pollutant objPollutant = new Pollutant(); objPollutant.FetchAddPollutants(objStationList); } } } catch (Exception ex) { string message = ex.ToString(); } }