Ejemplo n.º 1
0
        public void Edit_Normal_Conditions()
        {
            var repo   = new SurveyRepository();
            var survey = new Survey("Test Survey", DateTime.Today.AddDays(1),
                                    DateTime.Today.AddDays(2), "Description",
                                    options, owner);

            repo.Add(survey);
            survey.Color = "#800000";
            repo.Edit(survey);
        }
Ejemplo n.º 2
0
        public void Add_Normal_Condition()
        {
            var repo   = new SurveyRepository();
            var survey = new Survey("Test Survey", DateTime.Today.AddDays(1),
                                    DateTime.Today.AddDays(2), "Description",
                                    options, owner);

            repo.Add(survey);

            Assert.True(repo.GetAll().Last().Author != null);
        }
Ejemplo n.º 3
0
        public async Task <Survey> GenerateSurvey(SubmissionData data, List <List <Snapshot> > assignmentSnapshots)
        {
            var snapshots = assignmentSnapshots.SelectMany(s => s);
            var survey    = new Survey()
            {
                Snapshots = snapshots.ToList(),
                Student   = data.Student,
            };
            await SurveyRepository.Add(survey);

            return(survey);
        }
        private void btnSaveSurvey_Click(object sender, EventArgs e)
        {
            Survey survey = CreateSurvey();

            FormHelper.ClearErrors(grpSurveySettings, errorProvider);

            if (ValidateSurvey(survey))
            {
                _sRepository.Add(survey);
                Close();
            }
        }
Ejemplo n.º 5
0
        public void Edit_Null_Argument()
        {
            var repo   = new SurveyRepository();
            var survey = new Survey("Test Survey", DateTime.Today.AddDays(1),
                                    DateTime.Today.AddDays(2), "Description",
                                    options, owner);

            repo.Add(survey);
            Assert.Catch <ArgumentNullException>(() =>
            {
                survey.Color = null;
                repo.Edit(survey);
            });
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Submit(SurveyInput input)
        {
            var token = HttpContext.Request.Headers["Authorization"].Last().Split(" ").Last();
            var roles = new List <string>()
            {
                "User", "Admin", "SchoolAdmin"
            };
            var handler  = new JwtSecurityTokenHandler();
            var sub      = handler.ReadJwtToken(token).Payload.Sub;
            var surveyId = new UserDetailsRepository().GetByUserId(sub).Id;

            if (RoleService.CheckRoles(token, roles, _userManager))
            {
                var survey = SurveyInputConverter.Convert(input, surveyId);
                _repository.Add(survey);

                return(CreatedAtAction("Submit", survey));
            }
            return(Unauthorized("Only User, Admin, SchoolAdmin have access to this controller."));
        }
Ejemplo n.º 7
0
 public void AddSurvey(Survey item)
 {
     surveyRepository.Add(item);
 }