protected void CadastrarTarefa(object sender, EventArgs e)
        {
            idUsuario = Convert.ToInt16(Session["Usuario"].ToString());

            if (String.IsNullOrEmpty(txtDescricao.Text) || String.IsNullOrEmpty(txtPrazo.Text) || String.IsNullOrEmpty(txtTarefa.Text) ){
                throw new Exception("É necessário que os 3 campos estejam preenchidos!");
            }

            Tarefa tarefa = new Tarefa()
            {
                DataDeEntrega = DateTime.Parse(txtPrazo.Text),
                Descricao = txtDescricao.Text,
                Nome = txtTarefa.Text,
                IdUsuario = idUsuario
            };

            using(negocio = new NegocioTarefa())
            {
                negocio.CadastrarTarefa(tarefa);
            }

            gridTodasAsTarefasDataBind();
            gridTarefasAVencerDataBind();
            gridTarefasExecutadasDataBind();
            gridTarefasVencidasDataBind();
        }
 public void CadastrarTarefa(Tarefa tarefa)
 {
     using (dao = new TarefaDao())
     {
         dao.Criar(tarefa);
     }
 }
        public void AlterarTarefa(Tarefa tarefa)
        {
            using (dao = new TarefaDao())
            {
                Tarefa tarefaBanco = dao.BuscarPorId(tarefa.Id);
                tarefaBanco.DataDeEntrega = tarefa.DataDeEntrega;
                tarefaBanco.Descricao = tarefa.Descricao;
                tarefaBanco.Estado = tarefa.Estado;
                tarefaBanco.Nome = tarefa.Nome;

                dao.Editar(tarefa);
            }
        }
        public void Criar(Tarefa tarefa)
        {
            try
            {
                using(ConexaoDeDados conexao = new ConexaoDeDados()){
                    conexao.TbTarefa.Add(tarefa);
                    conexao.SaveChanges();

                }
            }catch
            {
                throw;
            }
        }
        public void GravarTarefa()
        {
            int usuarioId = 1;
            Tarefa entregarArtigo = new Tarefa()
            {
                DataDeEntrega = new DateTime(2015, 10, 30),
                Descricao = "Entregar Artigo de refactoring para o Joel",
                IdUsuario = usuarioId,
                Nome = "Entregar Artigo"
            };

            using(dao = new TarefaDao())
            {
                dao.Criar(entregarArtigo);
            }

            Assert.IsTrue(entregarArtigo.Id > 0);
        }
 public void Excluir(int id)
 {
     try
     {
         using (ConexaoDeDados conexao = new ConexaoDeDados())
         {
             Tarefa tarefa = new Tarefa();
             tarefa.Id = id;
             conexao.TbTarefa.Remove(tarefa);
             conexao.SaveChanges();
         }
     }
     catch
     {
         throw;
     }
 }
 public void Editar(Tarefa tarefa)
 {
     try
     {
         using (ConexaoDeDados conexao = new ConexaoDeDados())
         {
             conexao.Entry(tarefa).State = EntityState.Modified;
             conexao.SaveChanges();
         }
     }
     catch
     {
         throw;
     }
 }