public override void ExtraDelete(User user)
        {
            TaskRepo    repoTask    = new TaskRepo();
            LogWorkRepo repoWork    = new LogWorkRepo();
            CommentRepo repoComment = new CommentRepo();

            List <Task>    tasks    = repoTask.GetAll(t => t.creatorId == user.Id).ToList();
            List <Comment> comments = repoComment.GetAll().ToList();
            List <LogWork> works    = repoWork.GetAll().ToList();

            foreach (Task item in tasks)
            {
                foreach (Comment comment in comments)
                {
                    if (comment.taskId == item.Id)
                    {
                        repoComment.Delete(comment);
                    }
                }

                foreach (LogWork work in works)
                {
                    if (work.TaskId == item.Id)
                    {
                        repoWork.Delete(work);
                    }
                }

                repoTask.Delete(item);
            }
        }
        public void All()
        {
            var      logedUser = AuthenticationService.LoggedUser;
            TaskRepo repo      = new TaskRepo("tasks.txt");
            var      tasks     = repo.GetAll();

            Console.Clear();
            foreach (var task in tasks)
            {
                if (task.ParentId == logedUser.Id || task.ResponsibleUser == logedUser.Id)
                {
                    Console.Write("ID: ");
                    Console.WriteLine(task.Id);
                    Console.Write("Title: ");
                    Console.WriteLine(task.Title);
                    Console.Write("Description: ");
                    Console.WriteLine(task.Description);
                    Console.Write("ResponsibleUserID: ");
                    Console.WriteLine(task.ResponsibleUser);
                    Console.Write("Creator: ");
                    Console.WriteLine(task.Creator);
                    Console.Write("Status: ");
                    Console.WriteLine(task.Status);
                    Console.Write("LastChange: ");
                    Console.WriteLine(task.LastChange);
                    Console.Write("CreateTime: ");
                    Console.WriteLine(task.CreateTime);
                    Console.WriteLine("###############################");
                }
            }
        }
예제 #3
0
        private List <MTasks> GetTasksInfo()
        {
            TaskRepo      taskRepo  = new TaskRepo(tasksFilepath);
            List <MTasks> tasksList = new List <MTasks>();

            tasksList = taskRepo.GetAll();
            return(tasksList);
        }
예제 #4
0
        public JsonResult CreateTask(MainTaskViewModel taskDetails)
        {
            MainTask taskDetailsResults = new MainTask(taskDetails);

            _taskRepo.Insert(taskDetailsResults);
            var json = _taskRepo.GetAll();

            return(Json(json));
        }
        protected override void DeleteFilter(int id)
        {
            TaskRepo    taskRepository = RepositoryFactory.GetTasksRepository();
            List <Task> tasks          = taskRepository.GetAll().FindAll(task => task.UserId == id && task.ResponsibleUser == id);

            foreach (var task in tasks)
            {
                taskRepository.Delete(task);
            }

            List <Task> tasksRespU = taskRepository.GetAll();

            foreach (var task in tasksRespU)
            {
                if (task.ResponsibleUser == AuthenticationManager.LoggedUser.Id)
                {
                    task.UserId = AuthenticationManager.LoggedUser.Id;

                    taskRepository.Save(task);
                }
            }

            CommentRepo    comRepository = RepositoryFactory.GetCommentsRepository();
            List <Comment> comments      = comRepository.GetAll().FindAll(com => com.CreatedBy == id);

            foreach (var com in comments)
            {
                comRepository.Delete(com);
            }

            LoggedWorkRepo    loggedWorkRepo = RepositoryFactory.GetLoggedWorksRepository();
            List <LoggedWork> loggedWorks    = loggedWorkRepo.GetAll().FindAll(lw => lw.UserId == id);

            foreach (var lw in loggedWorks)
            {
                loggedWorkRepo.Delete(lw);
            }
        }
예제 #6
0
        //private List<MTasks> GetAllTasks()
        //{
        //    using (var db = new Index.BloggingContext())
        //    {
        //        var result =
        //           (from m in db.MTasks
        //            select m).ToList();
        //        return result;
        //    }
        //}

        //public List<MTasks> GetAllNF()
        //{
        //    using (var db = new Index.BloggingContext())
        //    {
        //        var result =
        //           (from m in db.MTasks
        //            where m.Final == false
        //            select m).ToList();
        //        return result;
        //    }
        //}

        //private List<TimeSpent> GetTTime()
        //{
        //    using (var db = new Index.BloggingContext())
        //    {
        //        MTasks user = (MTasks)tasksBindingSource1.Current;
        //        var result =
        //           (from t in db.TimeSpent
        //            where t.TheTask == user.TaskId
        //            select t).ToList();
        //        return result;
        //    }
        //}

        //private void NewTask(MTasks task)
        //{
        //    using (var db = new Index.BloggingContext())
        //    {
        //        var now = DateTime.Now;//.ToString("MM/dd/yyyy HH:mm:ss");
        //        var item = new MTasks { Title=task.Title, Description=task.Description, Creator=task.Creator, EstTime=task.EstTime, Assigned=task.Assigned, CreTime=now, Final=false };
        //        db.MTasks.Add(item);
        //        db.SaveChanges();
        //    }
        //}

        //private void EditTask(MTasks task)
        //{
        //    using (var db = new Index.BloggingContext())
        //    {
        //        var item =
        //                  (from m in db.MTasks
        //                   where m.TaskId == task.TaskId
        //                   select m).First();
        //        db.Database.ExecuteSqlCommand("UPDATE MTasks" +
        //                                       " SET Title={0},Description={1},EstTime={2},Assigned={3},Final={4}" +
        //                                        " WHERE TaskId={5}", task.Title, task.Description,
        //                                        task.EstTime, task.Assigned, task.Final, task.TaskId);
        //        db.SaveChanges();
        //    }
        //}

        //private void DeleteTask(MTasks task)
        //{
        //    using (var db = new Index.BloggingContext())
        //    {
        //        var item =
        //               (from m in db.MTasks
        //                where m.TaskId == task.TaskId
        //                select m).First();
        //        db.MTasks.Remove(item);
        //        db.SaveChanges();
        //    }
        //}

        //private void FinishTask(MTasks task)
        //{
        //    using (var db = new Index.BloggingContext())
        //    {
        //        var item =
        //                  (from m in db.MTasks
        //                   where m.TaskId == task.TaskId
        //                   select m).First();
        //        db.Database.ExecuteSqlCommand("UPDATE MTasks" +
        //                                       " SET Final={0}" +
        //                                        " WHERE TaskId={1}", true, task.TaskId);
        //        db.SaveChanges();
        //    }
        //}

        #endregion

        #region Old

        private void SetDataSources()
        {
            TaskRepo gat = new TaskRepo();

            tasksBindingSource1.DataSource = gat.GetAll();
            dataGridView1.DataSource       = tasksBindingSource1;

            UserRepo frm = new UserRepo();
            DataGridViewComboBoxColumn columnCreatedyBy = (DataGridViewComboBoxColumn)dataGridView1.Columns[4];

            columnCreatedyBy.DataSource = frm.GetAll();

            DataGridViewComboBoxColumn columnExecutive = (DataGridViewComboBoxColumn)dataGridView1.Columns[5];

            columnExecutive.DataSource = frm.GetAll();
        }
예제 #7
0
        private void ListAll()
        {
            Console.Clear();

            TaskRepo      taskRepo = new TaskRepo(tasksFilepath);
            List <MTasks> tasks    = taskRepo.GetAll();

            foreach (MTasks task in tasks)
            {
                Console.WriteLine();
                Console.WriteLine("Task id: " + task.TaskId);
                Console.WriteLine("Title: " + task.Title);
                Console.WriteLine("Description: " + task.Description);
                Console.WriteLine("Creators id: " + task.Creator);
                Console.WriteLine("Time for the task: " + task.EstTime);
                Console.WriteLine("Task executive id: " + task.Assigned);
                Console.WriteLine("Creation time: " + task.CreTime);
                Console.WriteLine("------------------------------------------------------");
            }

            Console.ReadKey(true);
        }