static public Models.ATM[] GetATMS() { var uri = "http://api.bocapi.net/v1/api/banks/bda8eb884efcef7082792d45/atms"; var webrequest = (HttpWebRequest)System.Net.WebRequest.Create(uri); webrequest.Headers.Add("Ocp-Apim-Subscription-Key", ""); webrequest.Headers.Add("Ocp-Apim-Subscription-Key", "d4af6bd7a1164d8eb6c6fca3c72a809a"); Models.ATM atm = new Models.ATM(); Models.ATM[] atms = new Models.ATM[] { }; using (var response = webrequest.GetResponse()) using (var reader = new StreamReader(response.GetResponseStream())) { //var result = ; dynamic results = JsonConvert.DeserializeObject <dynamic>(reader.ReadToEnd()); int i = 0; foreach (var item in results.atms) { atm.Name = item.name.Value; atm.latitude = item.location.latitude.Value; atm.longitude = item.location.longitude.Value; atms[i] = atm; i++; } } return(atms); }
public IHttpActionResult PutATM(int id, Models.ATM aTM) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != aTM.id) { return(BadRequest()); } db.Entry(aTM).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ATMExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetATMS() { Models.ATM[] atms = new Models.ATM[] { }; // Retrieve User and Merchant account id's from database atms = DataAccess.bocApi.GetATMS(); return(Ok(atms)); }
public IHttpActionResult PostATM(Models.ATM aTM) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.ATMs.Add(aTM); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = aTM.id }, aTM)); }
public IHttpActionResult DeleteATM(int id) { Models.ATM aTM = db.ATMs.Find(id); if (aTM == null) { return(NotFound()); } db.ATMs.Remove(aTM); db.SaveChanges(); return(Ok(aTM)); }
private ATM() { dataPath = System.IO.Path.Combine(new System.IO.FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).Directory.FullName, "Data"); file = System.IO.Path.Combine(dataPath, "ATM.json"); Model = new Models.ATM(); View = new Views.FormATM(); Config = new Views.FormConfig(); View.Shown += View_Shown; View.FormClosing += View_Closing; Config.FormClosing += Config_FormClosing; Load(); }
public IHttpActionResult GetATM(int id) { DateTime d1, d2; d1 = DateTime.Now; d2 = d1.AddHours(-1); Models.ATM aTM = db.ATMs.Find(id); if (aTM == null) { return(NotFound()); } else { SimulationController.trunsaction_Between_date(id, d2, d1); aTM = db.ATMs.Find(id); return(Ok(aTM)); } }