public async Task <IActionResult> Delete(ActivityDeleteViewModel activityDeleteViewModel) { var id = activityDeleteViewModel.Id; await this.activitiesService.DeleteByIdAsync(id); return(this.RedirectToAction("Index", "Activities", new { area = "" })); }
public ActionResult DeleteConfirmed(ActivityDeleteViewModel advm) { int?id = (int?)Session["activityid"]; if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } try { Activity activity = db.Activities.Find(id); DeleteDocs(activity.Files.ToArray()); db.Activities.Remove(activity); db.SaveChanges(); TempData["alert"] = "success|Aktiviteten togs bort!"; } catch (RetryLimitExceededException) { // Log errors here TempData["alert"] = "danger|Det gick inte att ta bort aktiviteten!"; } return(PartialView("_Delete", advm)); }