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)); }
public ActionResult Details(int?id) { // Make sure the user is logged in and that they have permission if (!IsUserLoggedIn) { return(RedirectToLogin()); } if (!UserHasPermission(PermissionName.ProjectOffering)) { return(RedirectToPermissionDenied()); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } try { int projectOfferingId = ( int )id; var projectOfferingModel = ProjectOfferingProcessor.SelectProjectOfferingForProjectOfferingId(projectOfferingId); if (projectOfferingModel == null) { return(RedirectToIndexIdNotFound(projectOfferingId)); } var project = ProjectProcessor.GetProject(projectOfferingModel.ProjectId); var unitOffering = UnitOfferingProcessor.SelectUnitOfferingForUnitOfferingId(projectOfferingModel.UnitOfferingId); var teams = TeamProcessor.SelectTeamsForProjectOfferingId(projectOfferingModel.ProjectOfferingId); var projectOffering = new ProjectOffering(projectOfferingModel, project, unitOffering, teams); return(View(projectOffering)); } catch (Exception e) { return(RedirectToIndex(e)); } }