Beispiel #1
0
        public bool Edit(models.Tarefas tarefa)
        {
            bool updated = false;

            using (var uow = DbHelper.UnitOfWork(nameof(TarefasContext)))
                using (var repository = uow.Repository <models.Tarefas>())
                {
                    var tarefaEdit = repository.ListWhere(new List <Expression <Func <models.Tarefas, object> > > {
                    }, s => s.Id_Tarefa == tarefa.Id_Tarefa).FirstOrDefault();

                    tarefaEdit.Data_Edicao    = DateTime.Now;
                    tarefaEdit.Descricao      = tarefa.Descricao;
                    tarefaEdit.Titulo         = tarefa.Titulo;
                    tarefaEdit.Data_Conclusao = tarefa.Data_Conclusao;
                    tarefaEdit.Status         = tarefa.Status;

                    repository.Update(tarefaEdit);

                    uow.SaveChanges();

                    updated = true;
                }

            return(updated);
        }
Beispiel #2
0
        public bool Add(models.Tarefas tarefa)
        {
            bool rowInserted = false;

            using (var uow = DbHelper.UnitOfWork(nameof(TarefasContext)))
            {
                using (var repository = uow.Repository <models.Tarefas>())
                {
                    tarefa.Data_Criacao = DateTime.Now;

                    repository.Add(tarefa);
                    uow.SaveChanges();

                    rowInserted = true;
                }
            }

            return(rowInserted);
        }
Beispiel #3
0
        public bool Remove(models.Tarefas tarefa)
        {
            bool rowRemoved = false;

            using (var uow = DbHelper.UnitOfWork(nameof(TarefasContext)))
            {
                using (var repository = uow.Repository <models.Tarefas>())
                {
                    var tarefaRemove = repository.ListWhere(new List <Expression <Func <models.Tarefas, object> > > {
                    }, s => s.Id_Tarefa == tarefa.Id_Tarefa).FirstOrDefault();
                    tarefaRemove.Data_Remocao = DateTime.Now;

                    repository.Delete(tarefaRemove);
                    uow.SaveChanges();

                    rowRemoved = true;
                }
            }

            return(rowRemoved);
        }