コード例 #1
0
ファイル: AlunoService.cs プロジェクト: thiagosartor/newBack
        public void Add(AlunoDTO alunoDto)
        {
            Turma turma = _turmaRepository.GetById(alunoDto.TurmaId);

            Aluno aluno = new Aluno(alunoDto.Descricao.Split(':')[0], turma ?? new Turma(2007));//todo: turma vem null

            aluno.Endereco.Bairro = alunoDto.Bairro;
            aluno.Endereco.Cep = alunoDto.Cep;
            aluno.Endereco.Localidade = alunoDto.Localidade;
            aluno.Endereco.Uf = alunoDto.Uf;

            _alunoRepository.Add(aluno);
        }
コード例 #2
0
ファイル: AlunoDTO.cs プロジェクト: thiagosartor/newBack
 public AlunoDTO(Aluno aluno)
 {
     Id = aluno.Id;
     Descricao = aluno.ToString();
     TurmaId = aluno.Turma.Id;
 }
コード例 #3
0
 public void Delete(Aluno entity)
 {
     Delete(SqlDelete, Take(entity));
 }
コード例 #4
0
        public Aluno Add(Aluno entity)
        {
            Insert(SqlInsert, Take(entity));

            return entity;
        }
コード例 #5
0
 private static object[] Take(Aluno aluno)
 {
     return new object[]
     {
         "Id", aluno.Id,
         "Nome", aluno.Nome,
         "Turma_Id", aluno.Turma.Id,
         "Endereco_Cep", aluno.Endereco.Cep,
         "Endereco_Localidade", aluno.Endereco.Localidade,
         "Endereco_Bairro", aluno.Endereco.Bairro,
         "Endereco_Uf", aluno.Endereco.Uf
     };
 }
コード例 #6
0
        private static Aluno Make(IDataReader reader)
        {
            Aluno aluno = new Aluno();
            aluno.Id = Convert.ToInt32(reader["Id"]);
            aluno.Nome = Convert.ToString(reader["Nome"]);
            aluno.Turma.Id = Convert.ToInt32(reader["Turma_Id"]); //TODO: Tirei o protected da Entity
            aluno.Endereco.Cep = Convert.ToString(reader["Endereco_Cep"]);
            aluno.Endereco.Localidade = Convert.ToString(reader["Endereco_Localidade"]);
            aluno.Endereco.Bairro = Convert.ToString(reader["Endereco_Bairro"]);
            aluno.Endereco.Uf = Convert.ToString(reader["Endereco_Uf"]);

            return aluno;
        }
コード例 #7
0
 public void Update(Aluno entity)
 {
     Update(SqlUpdate, Take(entity));
 }