Esempio n. 1
0
        public async Task <IActionResult> AddSurvey(Survey s)
        {
            await _surveyRepository.AddSurvey(s);

            ViewBag.Title = "Survey";
            return(View("Index"));
        }
Esempio n. 2
0
        public IActionResult AddSurvey([FromBody] Survey survey)
        {
            if (survey == null)
            {
                return(BadRequest());
            }

            var surveyId = _surveyRepository.AddSurvey(survey);
            var result   = _surveyRepository.GetSurvey(surveyId);


            return(Ok(result));
        }
        public IActionResult Post([FromBody] SurveyCreateDTO survey)
        {
            if (survey == null)
            {
                return(BadRequest());
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            // map dto to entity

            var surveyToAdd = new SurveyDTO
            {
                Name           = survey.Name,
                Description    = survey.Description,
                SurveyTypeCode = survey.SurveyTypeCode,
                Instructions   = survey.Instructions,
                IsLocked       = survey.IsLocked,

                CloseDate  = survey.CloseDate,
                CreateDate = survey.CreateDate,
                CreatedBy  = survey.CreatedBy,
                UpdateDate = survey.UpdateDate,
                UpdatedBy  = survey.UpdatedBy,

                SchoolYear = survey.SchoolYear,
                LeaverYear = survey.LeaverYear,
                IsReported = survey.IsReported,
                OpenDate   = survey.OpenDate
            };

            try
            {
                // save

                _rep.AddSurvey(surveyToAdd);
                _rep.Save();


                return(CreatedAtRoute("GetSurvey", new { id = surveyToAdd.Id }, surveyToAdd));
            }
            catch (AppException ex)
            {
                // return error message if there was an exception
                return(BadRequest(ex.Message));
            }
        }
Esempio n. 4
0
        public IActionResult Post([FromBody] Survey survey)
        {
            if (survey == null)
            {
                return(BadRequest());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var createdExpense = _surveyRepository.AddSurvey(survey);

            return(Created("Expense", createdExpense));
        }
Esempio n. 5
0
 public async Task <IActionResult> AddSurvey([FromBody] Survey survey)
 {
     return(Ok(await surveyRepository.AddSurvey(survey)));
 }
Esempio n. 6
0
 public ActionResult AddSurvey(Survey Survey)
 {
     ISurveyRepository.AddSurvey(Survey);
     ViewBag.Success = "Bedankt voor het invullen van de enquête!";
     return(View("~/Views/Payment/Success.cshtml"));
 }