public void Put(InfoViewModel viewModel) { //Send update to repo try { //throw new Exception("fooey"); ProjectRepository.UpdateProjectInfo(viewModel.InfoModel); } catch (Exception ex) { Logger.WarnException("Could not update TIP Project Info", ex); throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.ExpectationFailed) { ReasonPhrase = ex.Message }); } }
/// <summary> /// Gets a view model that can be used in the CreateProject view. /// Just contains the pick lists needed. /// </summary> /// <returns></returns> public InfoViewModel GetCreateProjectViewModel() { var result = new InfoViewModel(); // fill collections result.AvailableAdminLevels = GetLookupCollection("Lookup_GetProjectAdministrativeLevels", "Id", "Label"); result.AvailableSponsors = GetLookupCollection("Lookup_GetSponsorOrganizations", "Id", "Label"); result.AvailableImprovementTypes = GetLookupCollection("Lookup_GetImprovementTypes", "Id", "Label"); result.AvailableRoadOrTransitTypes = GetLookupCollection("Lookup_GetRoadOrTransitCategories", "Id", "Label"); result.AvailableProjectTypes = GetLookupCollection("Lookup_GetProjectTypes", "Id", "Label"); result.AvailableSelectionAgencies = GetLookupCollection("Lookup_GetSelectors", "Id", "Label"); return result; }
/// <summary> /// Get the select lists and the data to edit the "General Info" about a project /// </summary> /// <param name="versionId"></param> /// <param name="tipYear"></param> /// <returns></returns> public InfoViewModel GetProjectInfoViewModel(int versionId, string tipYear) { var result = new InfoViewModel(); // get project summary info result.InfoModel = GetProjectInfo(versionId, tipYear); //result.CdotData = GetCdotData(versionId); result.ProjectSummary = GetProjectSummary(versionId); result.ProjectSponsorsModel = GetProjectSponsorsModel(versionId, tipYear); if (result.InfoModel.SponsorId.HasValue && result.InfoModel.SponsorContactId.HasValue) { result.ProjectSponsorsModel.SponsorContact = GetSponsorContact(result.InfoModel.SponsorId.Value, result.InfoModel.SponsorContactId.Value); } if(!result.InfoModel.LocationMapId.Equals(default(int))) { result.InfoModel.Image = FileRepository.Load(result.InfoModel.LocationMapId); } // fill collections result.AvailableAdminLevels = AvailableAdminLevels;// GetLookupCollection("Lookup_GetProjectAdministrativeLevels", "Id", "Label"); //result.AvailableSponsors = AvailableSponsors;// GetLookupCollection("Lookup_GetSponsorOrganizations", "Id", "Label"); result.AvailableSponsors = GetAvailableTimePeriodSponsorAgencies(tipYear, _appState).ToDictionary(x => (int)x.OrganizationId, x => x.OrganizationName); result.AvailableImprovementTypes = AvailableImprovementTypes;// GetLookupCollection("Lookup_GetImprovementTypes", "Id", "Label"); result.AvailableRoadOrTransitTypes = AvailableRoadOrTransitTypes; // GetLookupCollection("Lookup_GetRoadOrTransitCategories", "Id", "Label"); //Fixed this next line. -DBD 02/03/2010 result.AvailableSponsorContacts = AvailableSponsorContacts(result.InfoModel);// GetSponsorContacts(result.InfoModel.SponsorId.Value); //result.AvailableSponsorContacts = // ((result.InfoModel.SponsorContactId > 0) && (result.InfoModel.SponsorId > 0)) ? // GetSponsorContacts(result.InfoModel.SponsorId.Value) // : new Dictionary<int, string>(); result.AvailableProjectTypes = AvailableProjectTypes;// GetLookupCollection("Lookup_GetProjectTypes", "Id", "Label"); result.AvailableSelectionAgencies = AvailableSelectionAgencies; // GetLookupCollection("Lookup_GetSelectors", "Id", "Label"); result.AvailablePools = AvailablePools(result.ProjectSummary);// GetPoolNames(1, result.ProjectSummary.TipYearTimePeriodID); // Can get ProgramID from Session. -DBD return result; }