public IActionResult DeleteIcon([FromForm] cardicons icons) { var data = _saveData.DeleteIcon(icons.iconId); //deleting image into local folder string[] files = Directory.GetFiles(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot" + "/uploadimgs/icons/")); foreach (string file in files) { var FileName = Path.GetFileNameWithoutExtension(file); var fileId = FileName.Split("_"); if (fileId[0] == icons.iconId.ToString()) { System.IO.File.Delete(file); } } var _listoficons = _saveData.GetAllIcons(); return(PartialView("_iconsList", _listoficons)); }
public async Task <ActionResult> createORUpdateIcon([FromForm] IFormCollection form, [FromForm] cardicons icons) { var data = _saveData.createORUpdateIcon(icons.iconId, icons.iconName, icons.iconFileName); foreach (var file in form.Files) { string[] files = Directory.GetFiles(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot" + "/uploadimgs/icons/")); foreach (string imgfile in files) { var FileName = Path.GetFileNameWithoutExtension(imgfile); var fileId = FileName.Split("_"); if (fileId[0] == icons.iconId.ToString()) { System.IO.File.Delete(imgfile); } } var iconfile = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot" + "/uploadimgs/icons/", data + "_" + file.FileName); using (var stream = new FileStream(iconfile, FileMode.Create)) { await file.CopyToAsync(stream); } } var _listoficons = _saveData.GetAllIcons(); return(PartialView("_iconsList", _listoficons)); }
public IActionResult GetIconById([FromForm] cardicons icons) { var data = _saveData.GetIconById(icons.iconId); return(Ok(data)); }