public ActionResult Delete() { try { string idDeleteAll = Request["DeleteId-checkbox"]; string[] arrDeleteId = idDeleteAll.Split(','); for (int i = 0; i < arrDeleteId.Count(); i++) { var item = CarsService.Get(int.Parse(arrDeleteId[i], CultureInfo.InvariantCulture)); if (item != null) { if (item.CreatedUserId != Helpers.Common.CurrentUser.Id && Helpers.Common.CurrentUser.UserTypeId != 1) { TempData["FailedMessage"] = "NotOwner"; return(RedirectToAction("Index")); } CarsService.DeleteRs(item); } } TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.DeleteSuccess; return(RedirectToAction("Index")); } catch (DbUpdateException) { TempData[Globals.FailedMessageKey] = App_GlobalResources.Error.RelationError; return(RedirectToAction("Index")); } }