public async Task <IActionResult> Delete(int id, int page = 1, int sort = 1, bool ascending = true) { var specifikacija = await _ctx.Specifikacije.FindAsync(id); if (specifikacija == null) { return(NotFound(id)); } else { try { _ctx.Remove(specifikacija); await _ctx.SaveChangesAsync(); var result = new { message = $"Specifikacija sa sifrom {id} obrisano.", successful = true }; return(Json(result)); } catch (Exception e) { var result = new { message = $"Pogreska prilikom bisanja specifikacije {e.Message}", successful = false }; return(Json(result)); } } }
public async Task <IActionResult> Delete(int id, int page = 1, int sort = 1, bool ascending = true) { var mjenjac = await _ctx.Mjenjaci.FindAsync(id); if (mjenjac == null) { return(NotFound(id)); } else { try { string naziv = mjenjac.Naziv; _ctx.Remove(mjenjac); await _ctx.SaveChangesAsync(); TempData[Constants.Message] = $"Mjenjac {naziv} uspjesno obrisan.*"; TempData[Constants.ErrorOccurred] = false; } catch (Exception e) { TempData[Constants.Message] = "Pogreska prilikom brisanja mjenjaca." + e.Message; TempData[Constants.ErrorOccurred] = true; return(RedirectToAction(nameof(Index))); } return(RedirectToAction(nameof(Index), new { page, sort, ascending })); } }
public IActionResult Delete(int id, int page = 1, int sort = 1, bool ascending = true) { var oprema = _ctx.DodatnaOprema.Find(id); if (oprema == null) { return(NotFound()); } else { try { _ctx.Remove(oprema); _ctx.SaveChanges(); var result = new { message = $"Oprema sa sifrom {id} obrisana.", successful = true }; return(Json(result)); } catch (Exception e) { var result = new { message = $"Pogreska prilikom bisanja artikla {e.Message}", successful = false }; return(Json(result)); } } }
public async Task <IActionResult> Delete(int id, int page = 1, int sort = 1, bool ascending = true) { var model = await _ctx.Modeli.FindAsync(id); if (model == null) { return(NotFound(id)); } else { try { _ctx.Remove(model); await _ctx.SaveChangesAsync(); var result = new { message = $"usluga sa model {id} obrisan.", successful = true }; return(Json(result)); } catch (Exception e) { var result = new { message = $"Pogreska prilikom bisanja model {e.Message}", successful = false }; return(Json(result)); } } }
public async Task <IActionResult> Delete(int IdBoje, int page = 1, int sort = 1, bool ascending = true) { var boja = await _ctx.Boje.FindAsync(IdBoje); if (boja == null) { return(NotFound(IdBoje)); } else { try { string naziv = boja.Naziv; _ctx.Remove(boja); await _ctx.SaveChangesAsync(); TempData[Constants.Message] = $"Boja {naziv} uspjesno obrisana.*"; TempData[Constants.ErrorOccurred] = false; } catch (Exception e) { TempData[Constants.Message] = "Pogreska prilikom brisanja boje." + e.Message; TempData[Constants.ErrorOccurred] = true; return(RedirectToAction(nameof(Index))); } return(RedirectToAction(nameof(Index), new { page, sort, ascending })); } }
public async Task <IActionResult> Delete(int id, int page = 1, int sort = 1, bool ascending = true) { var zaposlenik = await _ctx.Zaposlenici.FindAsync(id); if (zaposlenik == null) { return(NotFound(id)); } else { try { _ctx.Remove(zaposlenik); await _ctx.SaveChangesAsync(); var result = new { message = $"zaposlenik sa sifrom {id} obrisan.", successful = true }; return(Json(result)); } catch (Exception e) { var result = new { message = $"Pogreska prilikom bisanja zaposlenika {e.Message}", successful = false }; return(Json(result)); } } }