public JsonResult Delete(int id) { DataItem item = dataItemService.GetDataItem(id); if (item == null) { return(Json(new { status = HttpStatusCode.NoContent })); } var adminRole = memberService.GetUserRoles().SingleOrDefault(r => r.Name == MemberRoles.Admin.ToString()); ApplicationUser currUser = memberService.GetUser(User.Identity.Name); if (item.CreatedUser.UserName == User.Identity.Name || currUser.Roles.Any(r => r.RoleId == adminRole.Id)) { dataItemService.DeleteItem(item); dataItemService.SaveDataItem(); TempData["ReloadData"] = true; return(Json(new { status = HttpStatusCode.OK })); } return(Json("")); }