private static void cadastrar()
        {
            System.Console.WriteLine("Digite o nome:");
            string nome = System.Console.ReadLine();

            System.Console.WriteLine("Digite o salário");
            decimal salario = decimal.Parse(System.Console.ReadLine());

            var prof = new ProfessorDTO()
            {
                Nome    = nome,
                Salario = salario
            };

            Uri uri = new ProfessorRepository().Cadastrar(prof);

            if (uri != null)
            {
                System.Console.WriteLine("Url {0}", uri.ToString());
            }
            else
            {
                System.Console.WriteLine("Cadastro não realizado!");
            }
        }
        public async void RemoverProfessor(Professor professorDeletado)
        {
            if (professorDeletado.Id == 0 || !(Professores.Any(x => x.Id == professorDeletado.Id)))
            {
                await App.Current.MainPage.DisplayAlert("Ooops!", "O item selecionado p/ remoção não é válido!", "Ok");

                return;
            }

            var confirm = await App.Current.MainPage.DisplayAlert("Você tem certeza?", "Após a confirmação esta ação não poderá ser desfeita!", "Sim, remova!", "Cancelar");

            if (confirm)
            {
                var result = await ProfessorRepository.DeleteProfessorSqlAzureAsync(professorDeletado.Id.ToString());

                if (result)
                {
                    await App.Current.MainPage.DisplayAlert("Sucesso!", "Deletado com sucesso!", "Ok");

                    CarregarProfessores(true);
                    return;
                }
                else
                {
                    await App.Current.MainPage.DisplayAlert("Oops!", "Ocorreu um erro ao remover!", "Ok");
                }
            }
        }
Esempio n. 3
0
 public async Task Carregar()
 {
     await ProfessorRepository.GetProfessoresSqlAzureAsync().ContinueWith(retorno =>
     {
         CopiaListaProfessores = retorno.Result.ToList();
     });
     AplicarFiltro();
 }
        public async Task <bool> Carregar()
        {
            CopiaListaProfessores = await ProfessorRepository.GetProfessoresSqlAzureAsync();

            AplicarFiltro();

            return(true);
        }
Esempio n. 5
0
        public async Task Carregar()
        {
            await ProfessorRepository.GetProfessores().ContinueWith(retorno => {
                CopiarListaProfessores = retorno.Result.ToList();
            });

            Filtro();
        }
Esempio n. 6
0
 public OfferingsController()
 {
     _termRepository      = new TermRepository();
     _offeringRepository  = new OfferingRepository();
     _courseRepository    = new CourseRepository();
     _professorRepository = new ProfessorRepository();
     _scheduleRepository  = new ScheduleRepository();
 }
        private static void Listar()
        {
            IEnumerable <ProfessorDTO> lista = new ProfessorRepository().Listar();

            foreach (var item in lista)
            {
                System.Console.WriteLine("id: {0} Nome do Professor {1}, Salário {2}", item.Id, item.Nome, item.Salario);
            }
        }
Esempio n. 8
0
 public async void Adicionar(Professor paramProfessor)
 {
     if ((paramProfessor == null) || (string.IsNullOrWhiteSpace(paramProfessor.Nome)))
         await App.Current.MainPage.DisplayAlert("Atenção", "O campo nome é obrigatório", "OK");
     else if (await ProfessorRepository.PostProfessorSqlAzureAsync(paramProfessor))
         await App.Current.MainPage.Navigation.PopAsync();
     else
         await App.Current.MainPage.DisplayAlert("Falhou", "Desculpe, ocorreu um erro inesperado =(", "OK");
 }
Esempio n. 9
0
 public UnitOfWork(SWEContext context)
 {
     this.context = context;
     Facultie     = new FacultieRepository(context);
     Department   = new DepartmentRepository(context);
     Professor    = new ProfessorRepository(context);
     Student      = new StudentRepository(context);
     StudentLog   = new StudentLogRepository(context);
     Course       = new CourseRepository(context);
 }
Esempio n. 10
0
        public async void Carregar()
        {
            CopiaListaProfessores = await ProfessorRepository.GetProfessoresSqlAzureAsync();

            CopiaListaProfessores.ForEach(x => {
                Professores.Add(x);
            });

            AplicarFiltro();
        }
        public ProfessorViewModel()
        {
            OnSairCMD = new Command(OnSair);
            OnNovoCMD = new Command(OnNovo);
            OnAdicionarProfessorCMD = new OnAdicionarProfessorCMD(this);
            OnEditarProfessorCMD    = new OnEditarProfessorCMD(this);
            OnDeleteProfessorCMD    = new OnDeleteProfessorCMD(this);

            ProfessorList = ProfessorRepository.GetProfessoresSqlAzureAsync().Result;
        }
Esempio n. 12
0
        public async void Remove(Professor professor)
        {
            bool action = await App.Current.MainPage.DisplayAlert("Atenção", $"Deseja remover o {professor.Name}?", "Sim", "Não");

            if (action)
            {
                await ProfessorRepository.DeleteProfessorAsync(professor.Id);

                await App.Current.MainPage.DisplayAlert("Info", $"{professor.Name} removido com sucesso!", "Ok");
                await LoadProfessors();
            }
        }
Esempio n. 13
0
        public ProfessorViewModel()
        {
            var teste = ProfessorRepository.GetProfessoresSqlAzureAsync();

            OnAdicionarProfessorCMD = new OnAdicionarProfessorCMD(this);
            OnEditarProfessorCMD    = new OnEditarProfessorCMD(this);
            OnDeleteProfessorCMD    = new OnDeleteProfessorCMD(this);
            OnSairCMD = new Xamarin.Forms.Command(OnSair);
            OnNovoCMD = new Xamarin.Forms.Command(OnNovo);

            CopiaListaProfessores = new List <Professor>();
            Carregar();
        }
        public int RemoveProfessorScore(int?professoreCode, string term)
        {
            var scoreRepository = new ProfessorScoreRepository(new DatabaseFactory());
            var prof            = new ProfessorRepository(new DatabaseFactory());
            var professor       = prof.GetMany(x => x.ProfessorCode == professoreCode && x.Term.TermCode == term).FirstOrDefault();

            return(scoreRepository.Delete(x => x.Professor.Id == professor.Id &&
                                          !x.Score.Indicator.CountOfType.Contains("p7") &&
                                          !x.Score.Indicator.CountOfType.Contains("p11") &&
                                          !x.Score.Indicator.CountOfType.Contains("p12") &&
                                          !x.Score.Indicator.CountOfType.Contains("p16"), true));
            //else return -3000;
        }
        public async void CarregarProfessores(bool updateBase)
        {
            var professoresData = await ProfessorRepository.GetProfessoresSqlAzureAsync(updateBase);

            if (professoresData != null)
            {
                Professores.Clear();
                foreach (var prof in professoresData)
                {
                    Professores.Add(prof);
                }
            }
        }
Esempio n. 16
0
 public async void Remover()
 {
     if (await App.Current.MainPage.DisplayAlert("Atenção?",
         string.Format("Tem certeza que deseja remover o {0}?", Selecionado.Nome), "Sim", "Não"))
     {
         if (await ProfessorRepository.DeleteProfessorSqlAzureAsync(Selecionado.Id.ToString()))
         {
             CopiaListaProfessores.Remove(Selecionado);
             await Carregar();
         }
         else
             await App.Current.MainPage.DisplayAlert(
                     "Falhou", "Desculpe, ocorreu um erro inesperado =(", "OK");
     }
 }
 public async void Remover()
 {
     if (await App.Current.MainPage.DisplayAlert("Atenção",
                                                 string.Format("Tem certeza que deseja remover o {0}?", Professor.Nome), "Sim", "Não"))
     {
         if (ProfessorRepository.DeleteProfessorSqlAzureAsync(Professor.Id.ToString()).Result)
         {
             ProfessorList.Remove(Professor);
         }
         else
         {
             await App.Current.MainPage.DisplayAlert(
                 "Falhou", "Desculpe, ocorreu um erro inesperado =(", "OK");
         }
     }
 }
Esempio n. 18
0
        static void Main(string[] args)
        {
            Endereco obj = new Endereco();

            obj.Rua         = "Rue Cadillac";
            obj.Numero      = 4020;
            obj.Cep         = "H1R1H8";
            obj.Complemento = "Proximo ao metro Cadillac";
            obj.IdEndereco  = 1;

            EnderecoRepository rep = new EnderecoRepository();

            //rep.Insert(obj);
            Console.WriteLine("Endereço gravado com sucesso!");

            List <Endereco> lista = rep.SelectAll();

            foreach (var item in lista)
            {
                Console.WriteLine("Rua: " + item.Rua);
                Console.WriteLine("Numero: " + item.Numero);
                Console.WriteLine("Cep: " + item.Cep);
                Console.WriteLine("Complemento: " + item.Complemento);
                Console.WriteLine("*********************************");
            }

            Professor professor  = new Professor("Luka", 20.00, obj, "programacao");
            Professor professor1 = new Professor("Joao", 15.00, obj, "matematica");


            ProfessorRepository profrep = new ProfessorRepository();

            profrep.Insert(professor1);

            List <Professor> proflista = profrep.SelectAll();

            foreach (var item in proflista)
            {
                Console.WriteLine("Nome: " + item.Nome);
                Console.WriteLine("Salario: " + item.Salario);
                Console.WriteLine("Endereco: " + item.Endereco.Rua + "\n" + item.Endereco.Numero);
                Console.WriteLine("Disciplina: " + item.Disciplina);
                Console.WriteLine("*********************************");
            }

            Console.ReadKey();
        }
Esempio n. 19
0
        public async Task <ApiResponse> GetStateUser(string userId)
        {
            var isNumeric = int.TryParse(userId, out int resualt);

            try
            {
                if (isNumeric)
                {
                    var studentRepo = new StudentRepository();

                    var student       = studentRepo.Select(studentCode: userId);
                    var professorRepo = new ProfessorRepository();
                    var professor     = professorRepo.Select(professorCode: userId);

                    if (!(student is null))
                    {
                        var studentState = studentRepo.GetStateForTickets(studentCode: userId);
                        return(new ApiResponse
                        {
                            ErrorId = (int)Helper.ApiOutputError.NoError,
                            ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.NoError).ToString(),
                            Result = studentState
                        });
                    }
                    if (!(professor is null))
                    {
                        var professorState = new UserTicketState();
                        return(new ApiResponse
                        {
                            ErrorId = (int)Helper.ApiOutputError.NoError,
                            ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.NoError).ToString(),
                            Result = professorState
                        });
                    }
                }
                return(new ApiResponse
                {
                    ErrorId = (int)Helper.ApiOutputError.NotExists,
                    ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.NotExists).ToString(),
                    Result = null
                });
            }
            catch (System.Exception ex)
            {
                throw;
            }
        }
Esempio n. 20
0
        public ActionResult <ApiResponse> Get(Helper.ObjectType objectType, string code, int randomNumber)
        {
            var    smsRepository = new SmsRepository();
            string mobile;

            switch (objectType)
            {
            case Helper.ObjectType.Student:
                var studentRepository = new StudentRepository();
                mobile = studentRepository.Select(code).Mobile;

                return(new ApiResponse
                {
                    ErrorId = mobile == null || mobile.Trim() == ""
                        ? (int)Helper.ApiOutputError.NotExists
                        : (int)Helper.ApiOutputError.NoError,

                    ErrorTitle = mobile == null || mobile.Trim() == ""
                        ? ((Helper.ApiOutputError)Helper.ApiOutputError.NotExists).ToString()
                        : ((Helper.ApiOutputError)Helper.ApiOutputError.NoError).ToString(),

                    Result = $"{mobile}-{smsRepository.SendRandomNumber(mobile, randomNumber.ToString(), _config)}"
                });

            case Helper.ObjectType.Professor:

                var professorRepository = new ProfessorRepository();
                mobile = professorRepository.Select(code).Mobile;

                return(new ApiResponse
                {
                    ErrorId = mobile == null || mobile.Trim() == ""
                            ? (int)Helper.ApiOutputError.NotExists
                            : (int)Helper.ApiOutputError.NoError,

                    ErrorTitle = mobile == null || mobile.Trim() == ""
                            ? ((Helper.ApiOutputError)Helper.ApiOutputError.NotExists).ToString()
                            : ((Helper.ApiOutputError)Helper.ApiOutputError.NoError).ToString(),

                    Result = $"{mobile}-{smsRepository.SendRandomNumber(mobile, randomNumber.ToString(), _config)}"
                });

            default:
                return(new ApiResponse());
            }
        }
Esempio n. 21
0
        private async Task HandleEdit(Professor professor)
        {
            bool result = await ProfessorRepository.PutProfessorAsync(professor);

            if (result)
            {
                await App.Current.MainPage.Navigation.PopAsync();

                await App.Current.MainPage.DisplayAlert("Info", $"{professor.Name} editado com sucesso!", "Ok");

                await LoadProfessors();
            }
            else
            {
                await App.Current.MainPage.DisplayAlert("Atenção", $"Ocorreu um problema ao editar o {professor.Name}, " +
                                                        $"tente novamente mais tarde.", "Ok");
            }
        }
Esempio n. 22
0
        public async void Adicionar(Professor paramProfessor)
        {
            if ((paramProfessor == null) || (string.IsNullOrWhiteSpace(paramProfessor.Nome)))
            {
                await App.Current.MainPage.DisplayAlert("Atenção", "O campo nome é obrigatório", "OK");
            }

            var sucesso = await ProfessorRepository.PostProfessorSqlAzureAsync(paramProfessor);

            if (sucesso)
            {
                CopiaListaProfessores.Add(paramProfessor);
                Carregar();

                await App.Current.MainPage.Navigation.PopAsync();
            }
            else
            {
                await App.Current.MainPage.DisplayAlert("Falhou", "Desculpe, ocorreu um erro inesperado =(", "OK");
            }
        }
        public async void EditarProfessor(Professor professor)
        {
            if (string.IsNullOrWhiteSpace(professor.Nome) || string.IsNullOrWhiteSpace(professor.Titulo))
            {
                await App.Current.MainPage.DisplayAlert("Ooops!", "O item selecionado não é válido!", "Ok");

                return;
            }

            var result = await ProfessorRepository.PutProfessorSqlAzureAsync(professor);

            if (result)
            {
                await App.Current.MainPage.DisplayAlert("Sucesso!", "Professor editado com sucesso!", "Ok");

                await App.Current.MainPage.Navigation.PopAsync();

                return;
            }

            await App.Current.MainPage.DisplayAlert("Oops!", "Ocorreu um erro ao editar o professor!", "Ok");
        }
Esempio n. 24
0
        public async Task <ApiResponse> GetUser(string userId)
        {
            var isNumeric = int.TryParse(userId, out int resualt);

            if (isNumeric)
            {
                var studentRepo   = new StudentRepository();
                var student       = studentRepo.Select(studentCode: userId);
                var professorRepo = new ProfessorRepository();
                var professor     = professorRepo.Select(professorCode: userId);

                if (!(student is null))
                {
                    return new ApiResponse
                           {
                               ErrorId    = (int)Helper.ApiOutputError.NoError,
                               ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.NoError).ToString(),
                               Result     = student
                           }
                }
                ;
                if (!(professor is null))
                {
                    return new ApiResponse
                           {
                               ErrorId    = (int)Helper.ApiOutputError.NoError,
                               ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.NoError).ToString(),
                               Result     = professor
                           }
                }
                ;
            }
            return(new ApiResponse
            {
                ErrorId = (int)Helper.ApiOutputError.NotExists,
                ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.NotExists).ToString(),
                Result = null
            });
        }
Esempio n. 25
0
        public void Init()
        {
            conection  = new MSSQLDB(new DBConfiguration());
            _PREP      = new ProfessorRepository(conection);
            _encryptor = new Encryptor();
            handler    = new ProfessorQueryHandler(_PREP);

            var db = conection.GetCon();

            var    cpf      = "357.034.413-40";
            string password = cpf.Replace("-", "").Replace(".", "");

            password = _encryptor.Encrypt(password, out string salt);

            professor = new Professor("Lívia", "Emanuelly Elisa", cpf, "*****@*****.**", "(21) 2682-8370", EDegree.Master, password, salt);
            _PREP.Create(professor);

            commandGet = new ProfessorInputGet()
            {
                ProfessorId = professor.Id
            };
        }
        public async void NovoProfessor(Professor professor)
        {
            if (string.IsNullOrWhiteSpace(professor.Nome) || string.IsNullOrWhiteSpace(professor.Titulo))
            {
                await App.Current.MainPage.DisplayAlert("Alerta!", "Todos os campos são obrigatórios!", "OK");

                return;
            }

            // TODO: gerar um ID aletório com a data
            professor.Id = (int)((DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds / 516);

            var result = await ProfessorRepository.PostProfessorSqlAzureAsync(professor);

            if (result)
            {
                await App.Current.MainPage.DisplayAlert("Sucesso!", "Professor adicionado com sucesso!", "Ok");

                await App.Current.MainPage.Navigation.PopAsync();

                return;
            }
        }
Esempio n. 27
0
        public void Init()
        {
            conection  = new MSSQLDB(new DBConfiguration());
            _PREP      = new ProfessorRepository(conection);
            _encryptor = new Encryptor();
            handler    = new ProfessorCommandHandler(_PREP, _encryptor);

            var db = conection.GetCon();

            var    cpf      = "357.034.413-40";
            string password = cpf.Replace("-", "").Replace(".", "");

            password = _encryptor.Encrypt(password, out string salt);

            professor = new Professor("Lívia", "Emanuelly Elisa", cpf, "*****@*****.**", "(21) 2682-8370", EDegree.Master, password, salt);
            _PREP.Create(professor);

            commandRegister = new ProfessorInputRegister()
            {
                FirstName = "Lívia",
                LastName  = "Emanuelly Elisa",
                CPF       = cpf,
                Email     = "*****@*****.**",
                Phone     = "(21) 2682-8370",
                Degree    = EDegree.Master
            };

            commandUpdate = new ProfessorInputUpdate()
            {
                ProfessorId = professor.Id,
                FirstName   = "Lívia",
                LastName    = "Emanuelly Elisa",
                Email       = "*****@*****.**",
                Phone       = "(21) 2682-8370",
                Degree      = EDegree.Master
            };
        }
Esempio n. 28
0
        public ActionResult <ApiResponse> GetPicture(string code)
        {
            var studentRepo    = new StudentRepository();
            var studentPicture = studentRepo.Select(code, true)?.Picture;

            if (studentPicture != null)
            {
                return(new ApiResponse
                {
                    ErrorId = (int)Helper.ApiOutputError.NoError,
                    ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.NoError).ToString(),
                    Result = studentPicture
                });
            }

            var professorRepo    = new ProfessorRepository();
            var professorPicture = professorRepo.Select(code, true)?.Picture;

            if (professorPicture != null)
            {
                return(new ApiResponse
                {
                    ErrorId = (int)Helper.ApiOutputError.NoError,
                    ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.NoError).ToString(),
                    Result = professorPicture
                });
            }



            return(new ApiResponse
            {
                ErrorId = (int)Helper.ApiOutputError.NotExists,
                ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.NotExists).ToString(),
                Result = "default"
            });
        }
Esempio n. 29
0
        public ActionResult <ApiResponse> Get(string code)
        {
            var studentRepo = new StudentRepository();
            var student     = studentRepo.Select(code);

            if (student != null)
            {
                return(new ApiResponse
                {
                    ErrorId = (int)Helper.ApiOutputError.NoError,
                    ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.NoError).ToString(),
                    Result = student.Active
                });
            }

            var professorRepo = new ProfessorRepository();
            var professor     = professorRepo.Select(code);

            if (professor != null)
            {
                student.ObjectType = Helper.ObjectType.Professor;
                return(new ApiResponse
                {
                    ErrorId = (int)Helper.ApiOutputError.NoError,
                    ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.NoError).ToString(),
                    Result = professor.Active
                });
            }


            return(new ApiResponse
            {
                ErrorId = (int)Helper.ApiOutputError.NotExists,
                ErrorTitle = ((Helper.ApiOutputError)Helper.ApiOutputError.NotExists).ToString(),
                Result = "default"
            });
        }
 public ProfessorController()
 {
     repo = new ProfessorRepository();
 }