public ActionResult Delete(Team team)
        {
            // Make sure the user is logged in and that they have permission
            if (!IsUserLoggedIn)
            {
                return(RedirectToLogin());
            }
            if (!UserHasPermission(PermissionName.Team))
            {
                return(RedirectToPermissionDenied());
            }

            try
            {
                int rowsDeleted = TeamProcessor.DeleteTeam(team.TeamId);
                if (rowsDeleted <= 0)
                {
                    throw new DataException("Unable to Delete Team.");
                }

                return(RedirectToAction("Details", new RouteValueDictionary(
                                            new { controller = "ProjectOffering", action = "Details", Id = team.ProjectOfferingId })));
            }
            catch (Exception e)
            {
                // Show any errors
                ModelState.AddModelError("", e.Message);
            }

            //Find Team
            var teamModel       = TeamProcessor.GetTeamForTeamId(team.TeamId);
            var projectOffering = ProjectOfferingProcessor.SelectProjectOfferingForProjectOfferingId(teamModel.ProjectofferingId);

            return(View(new Team(teamModel, projectOffering)));
        }
        public ActionResult Delete(ProjectOffering projectOffering)
        {
            // Make sure the user is logged in and that they have permission
            if (!IsUserLoggedIn)
            {
                return(RedirectToLogin());
            }
            if (!UserHasPermission(PermissionName.ProjectOffering))
            {
                return(RedirectToPermissionDenied());
            }

            try
            {
                if (db.GetProjectOffering(projectOffering.ProjectOfferingId) == null)
                {
                    throw new DataException("This Project Offering does not exist.");
                }

                var existingTeams = TeamProcessor.SelectTeamsForProjectOfferingId(projectOffering.ProjectOfferingId);
                foreach (var team in existingTeams)
                {
                    TeamProcessor.DeleteTeam(team.TeamId);
                }

                int rowsDeleted = ProjectOfferingProcessor.DeleteProjectOffering(projectOffering.ProjectOfferingId);
                if (rowsDeleted <= 0)
                {
                    throw new DataException("Unable to Delete ProjectOffering.");
                }

                // If delete successful return to Index
                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                // Show any errors
                ModelState.AddModelError("", e.Message);
            }
            // If unsuccessful return to View
            return(View(db));
        }