Esempio n. 1
0
        public async Task <IActionResult> PutSurveySection([FromRoute] int id, [FromBody] SurveySection surveySection)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != surveySection.Id)
            {
                return(BadRequest());
            }

            _context.Entry(surveySection).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SurveySectionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            SurveySection surveysection = db.SurveySection.Find(id);

            db.SurveySection.Remove(surveysection);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 3
0
        private static SurveyAnswer CreateQuestionResults(SurveySection section, SurveyQuestion question)
        {
            var answer = Entity.Create <SurveyAnswer>();

            answer.SurveyAnswerOriginalQuestionText = question.Name;
            answer.QuestionBeingAnswered            = question;
            answer.QuestionInSection = section;
            return(answer);
        }
 /// <summary>
 /// Constructs a single, default survey question DTO object.
 /// </summary>
 /// <param name="surveySection"></param>
 /// <returns></returns>
 private SurveySectionDTO BuildSurveyQuestionDto(SurveySection surveySection)
 {
     return(new SurveySectionDTO
     {
         SectionName = surveySection.SectionName,
         SectionId = surveySection.Id,
         AverageRating = _ratedSectionService.GetSectionAverage(surveySection.Id),
         SurveyQuestions = BuildSurveyQuestions(surveySection.SurveyQuestions),
     });
 }
Esempio n. 5
0
        //
        // GET: /SurveySection/Details/5

        public ActionResult Details(int id = 0)
        {
            SurveySection surveysection = db.SurveySection.Find(id);

            if (surveysection == null)
            {
                return(HttpNotFound());
            }
            return(View(surveysection));
        }
Esempio n. 6
0
 public ActionResult Edit(SurveySection surveysection)
 {
     if (ModelState.IsValid)
     {
         db.Entry(surveysection).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.SurveyHeaderID = new SelectList(db.SurveyHeader, "ID", "SurveyName", surveysection.SurveyHeaderID);
     return(View(surveysection));
 }
Esempio n. 7
0
        //
        // GET: /SurveySection/Edit/5

        public ActionResult Edit(int id = 0)
        {
            SurveySection surveysection = db.SurveySection.Find(id);

            if (surveysection == null)
            {
                return(HttpNotFound());
            }
            ViewBag.SurveyHeaderID = new SelectList(db.SurveyHeader, "ID", "SurveyName", surveysection.SurveyHeaderID);
            return(View(surveysection));
        }
Esempio n. 8
0
        public async Task <IActionResult> PostSurveySection([FromBody] SurveySection surveySection)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.SurveySection.Add(surveySection);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetSurveySection", new { id = surveySection.Id }, surveySection));
        }
Esempio n. 9
0
        public ActionResult Create(SurveySection surveysection)
        {
            if (ModelState.IsValid)
            {
                db.SurveySection.Add(surveysection);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.SurveyHeaderID = new SelectList(db.SurveyHeader, "ID", "SurveyName", surveysection.SurveyHeaderID);
            return(View(surveysection));
        }
        /// <summary>
        /// Constructs a single doctor survey section DTO object.
        /// </summary>
        /// <param name="doctor"></param>
        /// <param name="doctorSurveySection"></param>
        /// <returns></returns>
        private DoctorSurveySectionDTO BuildDoctorSurveySectionDto(Doctor doctor, SurveySection doctorSurveySection)
        {
            var doctorSurveySectionDto = new DoctorSurveySectionDTO
            {
                DoctorName    = doctor.Person.Name,
                AverageRating = _ratedSectionService
                                .GetDoctorSectionAverage(doctorSurveySection.Id, doctor.Id),
                SectionId       = doctorSurveySection.Id,
                SectionName     = doctorSurveySection.SectionName,
                SurveyQuestions = BuildDoctorSurveyQuestions(doctor.Id, doctorSurveySection.SurveyQuestions)
            };

            return(doctorSurveySectionDto);
        }