public IActionResult Delete() { NoRoboComplaints Newrecord = new NoRoboComplaints(); Newrecord.id = "0"; return(View(Newrecord)); }
public IActionResult Created(NoRoboComplaints nerec) { dbContext.Database.EnsureCreated(); dbContext.Robocalls.Add(nerec); dbContext.SaveChanges(); return(View(nerec)); }
public IActionResult Viewed(NoRoboComplaints nerec) { var urlNameExists = dbContext.Robocalls.Any(x => x.id == nerec.id); NoRoboComplaints Newrecord = new NoRoboComplaints(); if (urlNameExists) { Newrecord = dbContext.Robocalls.Where(x => x.id == nerec.id).Select(x => new NoRoboComplaints() { id = x.id, company_phone_number = x.company_phone_number, violation_date = x.violation_date, created_date = x.created_date, consumer_area_code = x.consumer_area_code, consumer_city = x.consumer_city, consumer_state = x.consumer_state, subject = x.subject, Robocall = x.Robocall }).SingleOrDefault(); } else { Newrecord.id = "1"; } return(View(Newrecord)); }
public IActionResult Update() { NoRoboComplaints Newrecord = new NoRoboComplaints(); Newrecord.id = "0"; Newrecord.consumer_area_code = "None"; return(View(Newrecord)); }
public IActionResult Delete(NoRoboComplaints delreco) { NoRoboComplaints delrec = dbContext.Robocalls.Single(x => x.id == delreco.id); dbContext.Robocalls.Remove(delrec); dbContext.SaveChanges(); return(View(delrec)); }
public IActionResult Update(NoRoboComplaints uprec) { Console.WriteLine("I am here"); Console.WriteLine(uprec.consumer_area_code); if (uprec.consumer_area_code == null) { uprec.consumer_area_code = ""; } var urlNameExists = dbContext.Robocalls.Any(x => x.id == uprec.id); NoRoboComplaints updaterec = new NoRoboComplaints(); if (urlNameExists) { if (uprec.consumer_area_code == "") { updaterec = dbContext.Robocalls.Where(x => x.id == uprec.id).Select(x => new NoRoboComplaints() { id = x.id, company_phone_number = x.company_phone_number, violation_date = x.violation_date, created_date = x.created_date, consumer_area_code = x.consumer_area_code, consumer_city = x.consumer_city, consumer_state = x.consumer_state, subject = x.subject, Robocall = x.Robocall }).SingleOrDefault(); } else { updaterec = dbContext.Robocalls.FirstOrDefault(x => x.id == uprec.id); } if (uprec.consumer_area_code != "") { Console.WriteLine("here"); updaterec.company_phone_number = uprec.company_phone_number; updaterec.violation_date = uprec.violation_date; updaterec.created_date = uprec.created_date; updaterec.consumer_area_code = uprec.consumer_area_code; updaterec.consumer_city = uprec.consumer_city; updaterec.consumer_state = uprec.consumer_state; updaterec.subject = uprec.subject; updaterec.Robocall = uprec.Robocall; dbContext.SaveChanges(); } } else { updaterec.id = "1"; updaterec.consumer_area_code = "Not"; } return(View(updaterec)); }
public IActionResult Created() { string newID; while (true) { newID = RandomString(7); var urlNameExists = dbContext.Robocalls.Any(x => x.id == newID); if (!urlNameExists) { break; } } NoRoboComplaints Newrecord = new NoRoboComplaints(); Newrecord.id = newID; DateTime here = DateTime.Now; Newrecord.created_date = here; Newrecord.violation_date = here; Newrecord.consumer_city = null; return(View(Newrecord)); }
public IActionResult Refreshed() { inputstate newed = new inputstate(); //dbContext.Mitigate(); httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.Accept.Clear(); httpClient.DefaultRequestHeaders.Accept.Add( new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); string initialData = ""; //NoRoboComplaints Storehere = null; string apicall = base_url + "?api_key=" + API_key; httpClient.BaseAddress = new Uri(apicall); int c = 0; try { HttpResponseMessage response = httpClient.GetAsync(initial_json).GetAwaiter().GetResult(); if (response.IsSuccessStatusCode) { initialData = response.Content.ReadAsStringAsync().GetAwaiter().GetResult(); } if (!initialData.Equals("")) { //Console.WriteLine(initialData); Console.WriteLine("Starting"); var Storehere = JsonConvert.DeserializeObject <List <desRobo> > (initialData); Console.WriteLine("I am here"); Storehere.ForEach(p => { dbContext.Database.EnsureCreated(); Console.WriteLine("I am here too"); var urlNameExists = dbContext.Robocalls.Any(x => x.id == p.id); Console.WriteLine("I am here three"); if (!urlNameExists) { c = c + 1; Console.WriteLine("I am here FOUR"); NoRoboComplaints Newrecord = new NoRoboComplaints() { id = p.id, consumer_area_code = p.attributes.consumer_area_code, created_date = p.attributes.created_date, violation_date = p.attributes.violation_date, consumer_city = p.attributes.consumer_city, consumer_state = p.attributes.consumer_state, company_phone_number = p.attributes.company_phone_number, subject = p.attributes.subject, Robocall = p.attributes.Robocall }; dbContext.Robocalls.Add(Newrecord); dbContext.SaveChanges(); } }); } if (c == 0) { c = 10; } string t = c.ToString(); newed.state = c.ToString(); } catch (Exception e) { Console.WriteLine(e.Message); } return(View(newed)); }