public async Task <LecturesBean> GetStdInfo()
        {
            try
            {
                HttpResponseMessage response = await client.PostAsync(new Uri(Constants.Constants.Url_StdHome), new StringContent("", Encoding.UTF8, "application/json"));

                if (response.IsSuccessStatusCode)
                {
                    string value = await response.Content.ReadAsStringAsync();

                    List <LectureData>   lecturelist   = JsonConvert.DeserializeObject <List <LectureData> >(JObject.Parse(value)["atnlcSbjectList"].ToString());
                    List <TimeTableData> timeTableList = JsonConvert.DeserializeObject <List <TimeTableData> >(JObject.Parse(value)["timeTableList"].ToString());
                    List <NotiData>      notiList      = JsonConvert.DeserializeObject <List <NotiData> >(JObject.Parse(value)["subjNotiList"].ToString());
                    ProfessorData        professorData = JsonConvert.DeserializeObject <ProfessorData>(JObject.Parse(value)["rspnsblProfsr"].ToString());

                    LecturesBean bean = new LecturesBean();

                    bean.lectureList   = lecturelist;
                    bean.timeTableData = timeTableList;
                    bean.notiList      = notiList;
                    bean.professorData = professorData;
                    return(bean);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception e)
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
 protected async Task Load()
 {
     Professor               = new ProfessorData();
     Client                  = new HttpClient();
     Client.BaseAddress      = new Uri("https://trabalhocleber.azurewebsites.net");
     Professor.ProfessorInfo = await Client.GetJsonAsync <Professor>($"api/Professores/{ProfessorId}");
 }
 public async Task <IActionResult> RegistroProfessor([FromBody] Professor professor)
 {
     try
     {
         using (var data = new ProfessorData())
             data.Create(professor);
         return(Ok());
     }
     catch (Exception ex)
     {
         return(BadRequest($"Erro: {ex.Message}"));
     }
 }
Ejemplo n.º 4
0
        public ActionResult Create(IFormCollection pessoa)
        {
            int    PessoaId       = -1;
            string nome           = pessoa["nome"];  //<input name = "nome"
            string email          = pessoa["email"]; //<input emal = "email"
            string senha          = pessoa["senha"]; //<input senha = "senha"
            string dataNascimento = pessoa["datanascimento"];
            string telefone       = pessoa["telefone"];
            var    dataNasc       = DateTime.Parse(dataNascimento);

            var novaPessoa = new Pessoa();

            novaPessoa.Nome           = pessoa["nome"];
            novaPessoa.Email          = pessoa["email"];
            novaPessoa.Senha          = pessoa["senha"];
            novaPessoa.DataNascimento = pessoa["datanascimento"];
            novaPessoa.Telefone       = pessoa["telefone"];

            var professor = new Professor();

            professor.Nome           = pessoa["nome"];
            professor.Email          = pessoa["email"];
            professor.Senha          = pessoa["senha"];
            professor.DataNascimento = pessoa["datanascimento"];
            professor.Telefone       = pessoa["telefone"];
            try
            {
                using (var data = new PessoaData())
                    novaPessoa.PessoaId = data.Create(novaPessoa);
                using (var professordata = new ProfessorData())
                    professordata.Create(professor, novaPessoa);
                ViewBag.Message = "Sucesso Cadastro";
                return(View());
            }
            catch
            {
                ViewBag.Message = "Erro Cadastro";
                return(View());
            }
        }