// POST: Files/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
var fileModel = await _context.Files.SingleOrDefaultAsync(m => m.Id == id);
if (System.IO.File.Exists($"wwwroot{fileModel.Path}"))
{
System.IO.File.Delete($"wwwroot{fileModel.Path}");
}
_context.Files.Remove(fileModel);
await _context.SaveChangesAsync();
return RedirectToAction(nameof(Index));
}
[HttpPost]
public JsonResult Index(Currencies cur1, Currencies cur2) {
int SeachedId = -1;
foreach (Pair pair in _context.Pairs)
{
if (pair.Currency1 == cur1 && pair.Currency2 == cur2)
{
SeachedId = pair.Id;
}
}
var SeachedPair = _context.Pairs.Single(m => m.Id == SeachedId);
return Json(new{SeachedPair, _context.Rates});
}
[HttpGet]
public IActionResult Index()
{
return View();
}
getPare: function () {
if (this.Pare.Currency1 && this.Pare.Currency2) {
this.$http.post('http://localhost:5000/Rates?cur1=' + this.Pare.Currency1 + '&cur2=' + this.Pare.Currency2).then(response => {
console.log(response);
this.DataFromDb = response.body;
}, response => {
console.log("error")
})
}
},