Beispiel #1
0
        public async Task <string> CreateScenarioAsync([FromBody] ScenarioViewModel request)
        {
            // HttpRequest res = null;
            var response          = new ListModelResponse <ScenarioViewModel>();
            var scenarioDataModel = 0;

            try
            {
                //Logic to add new scenario comes here
                var maxscenId = await _scenarioRepository.GetMaxScenarioId(request.ProjectId.Value);

                request.MainScenarioId = Convert.ToString(Convert.ToInt32(maxscenId.FirstOrDefault()) + 1); //ends here
                scenarioDataModel      = await _scenarioRepository.CreateScenario(request.ToEntity());


                if (scenarioDataModel > 0)
                {
                    // response.Message = String.Format("Created User Successfully");
                    response.Message = Messages.CreateSuccessMsg;
                }
                else
                {
                    //response.Message = String.Format("Create User failed");
                    response.Message = Messages.CreateFailMsg;
                }
            }

            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.Message;
            }

            return(response.Message);
        }