public IActionResult DeleteRoad(string id) { var user = this.usersService.GetUserByUsername(this.User.Identity.Name); var road = roadsService.GetRoadById(id); if (road == null) { return(NotFound()); } if (!this.User.IsInRole(Constants.AdminRole)) { if (!this.User.IsInRole(Constants.OwnerRole)) { if (user.Id != road.UserId) { return(Unauthorized()); } } } bool result = roadsService.DeleteRoad(id); if (result == false) { return(this.RedirectToAction("Error")); } return(this.RedirectToAction("DeltedRoadSuccesfully", "Home")); }