public ActionResult Delete(int id, Report Report) { try { //authentication if (TempData.Peek("role") == null || (int)TempData.Peek("role") != 2) { TempData["msg"] = "Your role can not do this function!"; return(RedirectToAction("Logout", "Home")); } try { ReportRepository.DeleteReport(id); return(RedirectToAction(nameof(Index))); } catch (Exception ex) { ViewBag.Message = ex.Message; return(View()); } } catch (Exception ex) { TempData["msg"] = "Something went wrong! Logged out! Error: " + ex.Message;; return(RedirectToAction("Logout", "Home")); } }
public async Task <JsonResult> Delete(int item) { var _item = await _reportRepository.GetReport(item); await _reportRepository.DeleteReport(_item); return(Json(Ok())); }
public IActionResult DeleteReport(int id) { Report tempReport = _reportRepository.GetReportsById(id); tempReport.Reporter.NumberOfReports--; _reportRepository.DeleteReport(id); return(RedirectToAction("Index")); }
public async Task <ActionResult <IReadOnlyList <ReportToReturnDto> > > GetReportsToUser([FromBody] ReportToDeleteDto reportToDeleteDto) { var user = await _userRepo.GetUserByUserClaims(HttpContext.User); if (user == null) { return(Unauthorized("User is Unauthorized")); } var result = await _reportRepo.DeleteReport(reportToDeleteDto.Id); if (result) { return(Ok("Report Deleting Succeeded")); } return(BadRequest("Report Not Found")); }
public async Task <IActionResult> DeleteReport(int id, [Bind("Id, Title")] DeleteReportViewModel reportToDelete) { try { if (id != reportToDelete.Id) { return(NotFound()); } var oldReport = _reportRepository.GetReportById(id); if (oldReport != null) { var user = await _userManager.GetUserAsync(User); if (oldReport.Reporter.Id == user.Id) { if (ModelState.IsValid) { _reportRepository.DeleteReport(oldReport); return(RedirectToAction("ViewReports")); } else { return(View(reportToDelete)); } } else { return(Unauthorized()); } } else { return(NotFound()); } } catch (Exception e) { _logger.LogError(e.Message); return(View()); } }
public async Task DeleteReport(Guid id) { await _reportRepository.DeleteReport(id); }
public IActionResult DeleteById(int id) { _repo.DeleteReport(id); return(View()); }
public void DeleteReport(int companyId, Guid uniqueId) { _reportRepository.DeleteReport(companyId, uniqueId); }