Exemplo n.º 1
0
        /// <summary>
        ///     Creates a mapping from user roles to the appropriate methods for updating simulation analyses
        /// </summary>
        private Dictionary <string, SimulationAnalysisUpdateMethod> CreateUpdateMethods()
        {
            void UpdateSimulationAnalysis(SimulationAnalysisModel model, UserInformationModel userInformation) =>
            repo.UpdateSimulationAnalysis(model, db);
            void PartialUpdatePermittedSimulationAnalysis(SimulationAnalysisModel model, UserInformationModel userInformation) =>
            repo.PartialUpdatePermittedSimulationAnalysis(model, db, userInformation.Name);
            void PartialUpdatePermittedSimulationAnalysisWithoutWeights(SimulationAnalysisModel model, UserInformationModel userInformation) =>
            repo.PartialUpdatePermittedSimulationAnalysis(model, db, userInformation.Name, updateWeighting: false);

            return(new Dictionary <string, SimulationAnalysisUpdateMethod>
            {
                [Role.ADMINISTRATOR] = UpdateSimulationAnalysis,
                [Role.DISTRICT_ENGINEER] = PartialUpdatePermittedSimulationAnalysis,
                [Role.CWOPA] = PartialUpdatePermittedSimulationAnalysisWithoutWeights,
                [Role.PLANNING_PARTNER] = PartialUpdatePermittedSimulationAnalysis
            });
        }
Exemplo n.º 2
0
 public IHttpActionResult UpdateSimulationAnalysis([FromBody] SimulationAnalysisModel model)
 {
     repo.UpdateSimulationAnalysis(model, db);
     return(Ok());
 }