Beispiel #1
0
        public async Task <IActionResult> Create(CreateSurveyModel model)
        {
            var id = 0;

            if (ModelState.IsValid)
            {
                var dateTime   = DateTime.UtcNow;
                var dateOffset = dateTime.AddMinutes(model.NeedToBeFinishedFor.TotalMinutes);
                id = await _repository.AddAsync(new Survey
                {
                    Title                    = model.Title,
                    Text                     = model.Text,
                    CreatedAt                = dateTime,
                    Limit                    = model.Limit,
                    NeedToBeFinishedFor      = dateOffset,
                    NeedToBeFinishedForStart = dateTime,
                    Score                    = model.Score,
                    IsActive                 = false
                });


                return(RedirectToAction("CreateAdditionalInfo", "Survey", new { surveyId = id }));
            }


            return(View(model));
        }
Beispiel #2
0
        public async Task <int> CreateAsync(string title, string description)
        {
            var survey = new Survey(title, description);
            await _surveyRepository.AddAsync(survey);

            return(survey.Id);
        }
Beispiel #3
0
        public async Task AddSurvey(SurveyDto dto)
        {
            var survey = _mapper.Map <Survey>(dto);

            await _surveyRepository.AddAsync(survey);

            dto.Id = survey.Id;
        }