Ejemplo n.º 1
0
        // GET: api/Students/5
        //[ResponseType(typeof(Student))]

        public IHttpActionResult GetStudent(int id)
        {
            try
            {
                //Création d'un étudiant et de la mise en relation avec l'ID
                Student student = db.Students.FirstOrDefault(x => x.ID == id);
                // Création d'un student DTO ou semble il un view model d'après mes documentations
                StudentsDTO studentDTO = new StudentsDTO();
                List <Dictionary <string, string> > courseList = new List <Dictionary <string, string> >();

                // parcours Enrollment
                foreach (Enrollment enrollment in student.Enrollments)
                {
                    // Création du dictionnaire course
                    Dictionary <string, string> course = new Dictionary <string, string>();
                    // Parcours l'enrollment par le course ID
                    course["CourseID"] = enrollment.CourseID.ToString();
                    // ajoute une un cours  au dictionnaire lorsqur CoursID Correspond
                    courseList.Add(course);
                }
                //Affichage des données
                studentDTO.id             = student.ID;
                studentDTO.firstMidName   = student.FirstMidName;
                studentDTO.lastName       = student.LastName;
                studentDTO.enrollmentDate = student.EnrollmentDate;
                studentDTO.enrollments    = courseList;

                return(Ok(studentDTO));
            }
            catch
            {
                return(NotFound());
            }
        }
Ejemplo n.º 2
0
        private void listStudent()
        {
            string messageEmpty = String.Empty;

            if (txtSearchStudents.Text != String.Empty)
            {
                dtgListStudents.DataSource = StudentsDTO.getAllStudentsToDisplay(txtSearchStudents.Text);
                messageEmpty = "Não há aluno com esse critério!";
            }
            else
            {
                dtgListStudents.DataSource = StudentsDTO.getAllStudentsToDisplay();
                messageEmpty = "Não há aluno cadastrado!";
            }

            if (dtgListStudents.Columns.Count > 0)
            {
                dtgListStudents.Columns[0].Visible = false;
                dtgListStudents.Visible            = true;
                lblListStudentsEmpty.Visible       = false;
            }
            else
            {
                dtgListStudents.Visible      = false;
                lblListStudentsEmpty.Text    = messageEmpty;
                lblListStudentsEmpty.Visible = true;
            }
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> PutStudents([FromRoute] int id, [FromBody] StudentsDTO student)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

            _context.Entry(Mapper.Map <StudentsDTO>(student)).State = EntityState.Modified;

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

            return(NoContent());
        }
 public IActionResult DeleteStudent([FromBody] StudentsDTO student)
 {
     try
     {
         Boolean     Status   = StudentService.DeleteStudent(student.Id);
         ResponseDTO response = new ResponseDTO();
         if (Status == true)
         {
             response.StatusCode = "Success";
             response.Message    = "Successfully Deleted";
             response.Data       = Status;
             return(Ok(response));
         }
         else
         {
             response.StatusCode = "Warning";
             response.Message    = "Can't Delete";
             response.Data       = false;
             return(BadRequest(response));
         }
     }
     catch (Exception ex)
     {
         ResponseDTO Failure = new ResponseDTO();
         Failure.StatusCode = "Failed";
         Failure.Message    = ex.Message;
         Failure.Data       = false;
         return(BadRequest(Failure));
     }
 }
Ejemplo n.º 5
0
        private bool UpdateStudent()
        {
            Student newStudent = new Student(
                studentToEdit.Id,
                txtName.Text,
                txtCPF.Text,
                txtRG.Text,
                txtOrgExp.Text,
                dtpExp.Value.Date,
                dtpNasc.Value.Date,
                txtNaturalidade.Text,
                txtPai.Text,
                txtMae.Text,
                txtEnd.Text,
                txtCidade.Text,
                txtEstado.Text,
                txtBairro.Text,
                txtCep.Text,
                txtTel.Text,
                txtCelular.Text,
                txtEmail.Text,
                studentToEdit.Dt_created
                );

            if (StudentsDTO.UpdateStudent(newStudent))
            {
                this.studentToEdit = newStudent;
                return(true);
            }

            return(false);
        }
Ejemplo n.º 6
0
        public void AddStudents(StudentsDTO student)
        {
            var addStudent = mapper.Map <Student>(student);
            var group      = repoGroup.Read().FirstOrDefault(x => x.Name == student.GroupName);

            addStudent.Groups = group;
            repoStudent.Create(addStudent);
        }
Ejemplo n.º 7
0
        public IHttpActionResult Update(StudentsDTO student)
        {
            if (student == null)
            {
                NotFound();
            }

            return(Ok(new StudentsDTO().Update(student)));
        }
Ejemplo n.º 8
0
        public void DeleteStudent(StudentsDTO student)
        {
            var deleteStudent = mapper.Map <Student>(student);
            var group         = repoGroup.Read().FirstOrDefault(x => x.Name == student.GroupName);

            deleteStudent.Groups = group;
            var del = repoStudent.Read().FirstOrDefault(x => x.Id == deleteStudent.Id);

            repoStudent.Delete(del);
        }
Ejemplo n.º 9
0
        public IHttpActionResult GetStudent(int id)
        {
            var student = new StudentsDTO().GetStudent(id);

            if (student == null)
            {
                NotFound();
            }
            return(Ok(student));
        }
Ejemplo n.º 10
0
        public void UpdateStudent(StudentsDTO students)
        {
            var updateStudent = mapper.Map <Student>(students);
            var group         = repoGroup.Read().FirstOrDefault(x => x.Name == students.GroupName);

            updateStudent.Groups  = group;
            updateStudent.IdGroup = group.Id;
            var up = updateStudent;

            repoStudent.Update(up);
        }
Ejemplo n.º 11
0
        public StudentDetail(string id)
        {
            InitializeComponent();
            this.CenterToScreen();

            studentToEdit = StudentsDTO.getStudents(new Dictionary <string, string> {
                { "id", id }
            })[0];
            setFields();
            setLabels();
        }
Ejemplo n.º 12
0
        private void btnCreate_Click(object sender, RoutedEventArgs e)
        {
            StudentsDTO students = new StudentsDTO
            {
                Name      = tbName.Text,
                Surname   = tbSurname.Text,
                GroupName = cbGroup.SelectedItem.ToString()
            };

            service.AddStudents(students);
            Update(service);
        }
Ejemplo n.º 13
0
        public async Task <IActionResult> PostStudents([FromBody] StudentsDTO student)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Students.Add(Mapper.Map <Students>(student));
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetStudents", new { id = student.Id }, student));
        }
Ejemplo n.º 14
0
 private bool AddRelatorio()
 {
     return(ClassDTO.AddNewClass(new Class(
                                     0,
                                     this.radioControl["dig"],
                                     this.radioControl["lei"],
                                     this.radioControl["rec"],
                                     this.radioControl["atv"],
                                     this.radioControl["int"],
                                     StudentsDTO.getStudents(new Dictionary <string, string> {
         { "id", cmbNomeAluno.SelectedValue.ToString() }
     })[0],
                                     InstructorDTO.getInstructors(new Dictionary <string, string> {
         { "id", cmbNomeMonitor.SelectedValue.ToString() }
     })[0],
                                     ActivityDTO.getActivities(new Dictionary <string, string> {
         { "id", cmbActivities.SelectedValue.ToString() }
     })[0],
                                     dtpRelCreated.Value.Date,
                                     txtObs.Text,
                                     txtObsInteressante.Text
                                     )));
 }
Ejemplo n.º 15
0
 private bool AddNewStudent()
 {
     return(StudentsDTO.AddNewStudent(new Student(
                                          0,
                                          txtNome.Text,
                                          txtCPF.Text,
                                          txtRG.Text,
                                          txtOrgExp.Text,
                                          dtpExp.Value.Date,
                                          dtpNasc.Value.Date,
                                          txtNaturalidade.Text,
                                          txtPai.Text,
                                          txtMae.Text,
                                          txtEnd.Text,
                                          txtCidade.Text,
                                          txtEstado.Text,
                                          txtBairro.Text,
                                          txtCep.Text,
                                          txtTel.Text,
                                          txtCelular.Text,
                                          txtEmail.Text,
                                          DateTime.Today
                                          )));
 }
Ejemplo n.º 16
0
 private void _handlerRelatoriosCMBox()
 {
     setCMBoxValues(StudentsDTO.getAllStudentsName(), cmbNomeAluno);
     setCMBoxValues(InstructorDTO.getAllInstructorsName(), cmbNomeMonitor);
     setCMBoxValues(ActivityDTO.getAllActivitiesTitle(), cmbActivities);
 }
Ejemplo n.º 17
0
        public void AddNewStudent(StudentsDTO newStudent)
        {
            var Student = registerContext.Students.Add(AutoMapper.Mapper.Map <StudentsDTO, Students>(newStudent));

            registerContext.SaveChanges();
        }