예제 #1
0
        //creates task with attachment
        public ActionResult CreateWithFile(TaskViewModel task, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                var currentUserId = GetCurrentUserId();

                string pathToFile = SaveUploadedFile(file);

                TaskToDo taskToDo = task.TaskToDo;
                taskToDo.Id = Guid.NewGuid();
                Models.Folder folder = db.Folders.Find(task.FolderId);

                taskToDo.Folder             = folder;
                taskToDo.StartDate          = DateTime.Now;
                taskToDo.AppUserId          = currentUserId;
                taskToDo.PathToAttachedFile = pathToFile;

                db.TaskToDoes.Add(taskToDo);

                if (taskToDo.Description.Contains("#"))
                {
                    ManageHashtags(taskToDo);
                }

                db.SaveChanges();
                return(RedirectToAction("IndexWithFolders"));
            }

            return(View(task));
        }
예제 #2
0
        /// <summary>
        /// Change the current selected subtask
        /// </summary>
        /// <param name="selectedSubtask"></param>
        public void SelectCurrentSubTask(TaskToDo selectedSubtask)
        {
            RefreshContext refresher = new RefreshContext();

            SetSelectedSubTask(selectedSubtask, refresher);
            RefreshGui(refresher);
        }
예제 #3
0
        private void ManageHashtags(TaskToDo task)
        {
            Regex regex = new Regex(@"#\w+");

            foreach (Match match in regex.Matches(task.Description))
            {
                string tag = match.Value.Substring(1).ToLower();

                Hashtag hashtag = db.Hashtags.FirstOrDefault(h => h.Name == tag);

                if (hashtag == null)
                {
                    hashtag = CreateHashtag(tag, task);
                }

                if (hashtag.TasksWithHashtag == null)
                {
                    hashtag.TasksWithHashtag = new List <TaskToDo>();
                }

                if (!hashtag.TasksWithHashtag.Contains(task))
                {
                    hashtag.TasksWithHashtag.Add(task);
                }
            }
            db.SaveChanges();
        }
예제 #4
0
 /// <summary>
 /// changes the selected subtask (inside the current task)
 /// </summary>
 /// <param name="selectedSubtask"></param>
 /// <param name="refreshContext"></param>
 private void SetSelectedSubTask(TaskToDo selectedSubtask, RefreshContext refreshContext)
 {
     _selectedSubtask = selectedSubtask;
     refreshContext.CurrentTaskSoft = true;
     refreshContext.ContextMenus    = true;
     refreshContext.Description     = true;
 }
        public async override Task UpdateAsync(TaskToDo obj)
        {
            var taskToDo = await GetByIdAsync(obj.Id);

            obj.Status = taskToDo.Status;
            await base.UpdateAsync(obj);
        }
예제 #6
0
 /// <summary>
 /// default constructor but cannot called from outside
 /// </summary>
 private FormTaskEditor()
 {
     InitializeComponent();
     _convertor = new TaskToStringConvertor();
     _convertor.NbSpacesPerTabulation = NB_SPACES_PER_TABULATION;
     _task = null;
 }
        public async Task <IActionResult> Edit(int id, [Bind("TaskToDoId,NewTask,CompleteDate,IsCompleted,JobId")] TaskToDo taskToDo)
        {
            if (id != taskToDo.TaskToDoId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(taskToDo);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TaskToDoExists(taskToDo.TaskToDoId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index", "TaskToDoes"));
                // new { id = taskToDo.TaskToDoId }
            }
            ViewData["JobId"] = new SelectList(_context.Job, "JobId", "Position", taskToDo.JobId);
            return(View(taskToDo));
        }
예제 #8
0
        /// <summary>
        /// Create a new task
        /// </summary>
        public void CreateNewTask()
        {
            TaskToDo newTask = null;

            using (FormTaskEditor dialog = new FormTaskEditor("- New task"))
            {
                if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    newTask = dialog.Task;
                }
            }
            if (newTask != null)
            {
                //save the new task
                _tasks.AddTask(newTask);
                SaveTasksToFile();
                //select this new task
                _selectedTask    = newTask;
                _selectedSubtask = newTask;
                //Refresh GUI
                RefreshContext refresher = new RefreshContext();
                refresher.SetAll();
                RefreshGui(refresher);
            }
        }
예제 #9
0
        protected override void Seed(Capstone6Context context)
        {
            var teamMember = new TeamMember()
            {
                Name     = "Jill Palms",
                Email    = "*****@*****.**",
                Password = "******"
            };

            context.TeamMembers.Add(teamMember);

            var taskToDo = new TaskToDo()
            {
                AssignedTeamMember = teamMember,
                Description        = "Meeting with the Bobs",
                DueDate            = new DateTime(1990, 4, 20),
                IsDone             = false
            };

            context.TaskToDos.Add(taskToDo);

            context.SaveChanges();

            base.Seed(context);
        }
예제 #10
0
        private async void CheckboxCheckChanged(object sender, EventArgs e)
        {
            CheckBox checkBox = sender as CheckBox;
            TaskToDo task     = (from itm in tasks.Items
                                 where itm.Id == Convert.ToInt32(checkBox.Text)
                                 select itm).FirstOrDefault <TaskToDo>();
            Grid grid = checkBox.Parent as Grid;

            if (Settings.EnableAnimations)
            {
                #pragma warning disable CS4014
                grid.FadeTo(0.3, 100);
                #pragma warning restore CS4014
                await grid.ScaleTo(0.9, 100, Easing.SinIn);
            }
            trash.Add(task);
            trashIndex.Add(tasks.Items.IndexOf(task));
            if (trash.Count > Settings.ToDoListTrashSize)
            {
                trash.RemoveAt(0);
                trashIndex.RemoveAt(0);
            }
            tasks.Items.Remove(task);
            UndoLayout.IsVisible = true;
            if (Settings.EnableAnimations)
            {
                await UndoLayout.FadeTo(1, 100);
            }
            else
            {
                UndoLayout.Opacity = 1;
            }
        }
예제 #11
0
        /// <summary>
        /// Switch in edition mode for current task
        /// </summary>
        public void EditCurrentTask()
        {
            if (_selectedTask == null)
            {
                return;
            }
            TaskToDo editedTask = null;

            using (FormTaskEditor form = new FormTaskEditor(_selectedTask))
            {
                if (form.ShowDialog() == DialogResult.OK)
                {
                    editedTask = form.Task;
                }
            }
            if (editedTask != null)
            {
                //proceed to task replacement
                _tasks.ReplaceTask(_selectedTask, editedTask);
                SaveTasksToFile();
                //Change the selection with current task
                _selectedTask    = editedTask;
                _selectedSubtask = editedTask;
                //Refresh GUI
                RefreshContext refresher = new RefreshContext();
                refresher.SetAll();
                RefreshGui(refresher);
            }
        }
예제 #12
0
        /// <summary>
        /// Reload the list of all tasks
        ///
        /// </summary>
        /// <param name="tasks">the list of all tasks</param>
        /// <param name="selectedTask">the task to select, can be null if nothing is selected</param>
        public void HardRefreshListOfTasks(IEnumerable <TaskToDo> tasks, TaskToDo selectedTask)
        {
            _disableEvents = true;
            listViewAllTasks.Items.Clear();
            ListViewItem selectedItem = null;

            foreach (TaskToDo currentTask in tasks)
            {
                ListViewItem newItem = new ListViewItem(currentTask.Name);
                newItem.Tag = currentTask;
                FormatTaskItem(newItem, currentTask);
                listViewAllTasks.Items.Add(newItem);
                newItem.Selected = false;
                if (currentTask == selectedTask)
                {
                    newItem.Text = _selectedPrefix + newItem.Text;
                    selectedItem = newItem;
                }
                else
                {
                    newItem.Selected = false;
                }
            }
            if (selectedItem != null)
            {
                selectedItem.Selected = true;
            }

            _disableEvents = false;
        }
예제 #13
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Desc,DeadLine")] TaskToDo taskToDo)
        {
            if (id != taskToDo.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(taskToDo);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TaskToDoExists(taskToDo.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(taskToDo));
        }
예제 #14
0
 public TaskToDo CreateTaskToDo()
 {
     taskToDo = new TaskToDo()
     {
         Title = "Task from Builder", Start = DateTime.Now, DeadLine = DateTime.Now
     };
     return(taskToDo);
 }
예제 #15
0
 public TaskToDo CreateTaskToDoWithUser(int id)
 {
     taskToDo = new TaskToDo()
     {
         Title = "Task from Builder", Start = DateTime.Now, DeadLine = DateTime.Now, UserId = id
     };
     return(taskToDo);
 }
        public ActionResult DeleteConfirmed(int id)
        {
            TaskToDo taskToDo = db.TaskToDos.Find(id);

            db.TaskToDos.Remove(taskToDo);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public TaskToDo CreateTaskToDo()
 {
     taskToDo = new TaskToDo()
     {
         Title = "Task from Builder"
     };
     return(taskToDo);
 }
예제 #18
0
    public void Run()
    {
        ConfigureConsole();

        bool exit = false;

        do
        {
            PrintBorders();

            int  option         = 1;
            bool selectedOption = false;
            do
            {
                PrintMenu(option, Spanish);
                GetChosenOption(ref option, ref selectedOption);
            } while (!selectedOption);

            switch (option)
            {
            case 1:
                Calendar calendar = new Calendar(); calendar.Run();
                break;

            case 2:
                Contacts contacts = new Contacts(); contacts.Run();
                break;

            case 3:
                TaskToDo tasks = new TaskToDo(); tasks.Run();
                break;

            case 4:
                Notes notes = new Notes(); notes.Run();
                break;

            case 5:
                ConfigurationConsole config = new ConfigurationConsole();
                config.Run();
                break;

            case 6:
                CreditsScreen credits = new CreditsScreen();
                credits.Run();
                break;

            case 7:
                Spanish = !Spanish;
                break;

            case 0:
                exit = true;
                break;

            default: break;
            }
        } while (!exit);
    }
예제 #19
0
 /// <summary>
 /// changes the selected task (inside the list of tasks)
 /// </summary>
 /// <param name="selectedTask"></param>
 /// <param name="refreshContext"></param>
 private void SetSelectedTask(TaskToDo selectedTask, RefreshContext refreshContext)
 {
     _selectedTask    = selectedTask;
     _selectedSubtask = _selectedTask != null ? _selectedTask : null;
     refreshContext.ListOfTasksSoft = true;
     refreshContext.CurrentTaskHard = true;
     refreshContext.ContextMenus    = true;
     refreshContext.Description     = true;
 }
예제 #20
0
 /// <summary>
 /// constructor
 /// </summary>
 public MainFormControler(MainForm form)
 {
     _view                  = form;
     _tasks                 = new TaskCollection();
     _saveFileName          = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "TasksToDo.txt");
     _selectedTask          = null;
     _selectedSubtask       = null;
     _hideCompletedSubtasks = false;
 }
예제 #21
0
        /// <summary>
        /// 爬虫启动入口
        /// </summary>
        public void Start()
        {
            TaskToDo taskToDo = new TaskToDo();

            taskToDo.Start();

            GrabAllInfo grabAllInfo = new GrabAllInfo();

            grabAllInfo.Start();
        }
예제 #22
0
        public async void AddTaskAsync(string description, bool done)
        {
            var task = new TaskToDo()
            {
                Description = description, Done = done
            };

            dbContext.Tasks.Add(task);
            await dbContext.SaveChangesAsync();
        }
예제 #23
0
        public static void SeedDatabase(DatabaseContext context)
        {
            try
            {
                if (context.Developer.Any())
                {
                    return;
                }

                var frontendTask = new TaskToDo()
                {
                    Title    = "Dev HTML page",
                    Start    = DateTime.Now,
                    DeadLine = DateTime.Now.AddDays(15),
                    Status   = false
                };

                var backendTask = new TaskToDo()
                {
                    Title    = "Dev C# code",
                    Start    = DateTime.Now,
                    DeadLine = DateTime.Now.AddDays(15),
                    Status   = false
                };

                var frontend = new Developer()
                {
                    Name    = "Adler Pagliarini",
                    DevType = DevType.FrontEnd
                };
                frontend.AddItemToDo(frontendTask);

                var backend = new Developer()
                {
                    Name    = "Pagliarini Nascimento",
                    DevType = DevType.BackEnd
                };
                backend.AddItemToDo(backendTask);

                var fullstack = new Developer()
                {
                    Name    = "Adler Nascimento",
                    DevType = DevType.Fullstack
                };
                fullstack.AddItemToDo(frontendTask);
                fullstack.AddItemToDo(backendTask);

                context.Developer.AddRange(frontend, backend, fullstack);
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                Console.WriteLine($"[ERROR]: {ex.Message}");
            }
        }
 public ActionResult Edit([Bind(Include = "id,name,description,dueDate,isDone,budgetEstimate,categoryId")] TaskToDo taskToDo)
 {
     if (ModelState.IsValid)
     {
         db.Entry(taskToDo).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.categoryId = new SelectList(db.Categories, "id", "name", taskToDo.categoryId);
     return(View(taskToDo));
 }
예제 #25
0
        public async Task <IActionResult> Create([Bind("Id,Name,Desc,DeadLine")] TaskToDo taskToDo)
        {
            if (ModelState.IsValid)
            {
                _context.Add(taskToDo);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(taskToDo));
        }
 public ActionResult Edit([Bind(Include = "Id,TeamMemberId,Description,DueDate,IsDone")] TaskToDo taskToDo)
 {
     if (ModelState.IsValid)
     {
         db.Entry(taskToDo).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.TeamMemberId = new SelectList(db.TeamMembers, "Id", "Name", taskToDo.TeamMemberId);
     return(View(taskToDo));
 }
        public void CreateTaskTodoTest()
        {
            var task = new TaskToDo
            {
                Title       = "Title",
                Description = "Description",
                Status      = StatusEnum.Awaiting
            };

            _service.Create(task);

            _mockRepository.ReceivedWithAnyArgs().Add <TaskToDo>(default);
예제 #28
0
 /// <summary>
 /// click on the button OK
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnOK_Click(object sender, EventArgs e)
 {
     try
     {
         _task        = _convertor.StringToTask(txtTask.Text);
         DialogResult = DialogResult.OK;
     }
     catch (Exception ex)
     {
         ErrorBox(ex);
     }
 }
예제 #29
0
 /// <summary>
 /// Refresh format of treenode of current task. Can be called
 /// </summary>
 /// <param name="treenode"></param>
 private void SoftRefreshTreeNodeRecursive(TreeNode treenode)
 {
     if (treenode.Tag != null)
     {
         TaskToDo task = (TaskToDo)treenode.Tag;
         FormatSubtaskItem(treenode, task);
     }
     foreach (TreeNode childNode in treenode.Nodes)
     {
         SoftRefreshTreeNodeRecursive(childNode);
     }
 }
예제 #30
0
 /// <summary>
 /// occurs when the selection of the selected tasks changes
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void listViewAllTasks_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (!_disableEvents)
     {
         TaskToDo selectedTask = null;
         if (listViewAllTasks.SelectedItems.Count == 1)
         {
             selectedTask = (TaskToDo)listViewAllTasks.SelectedItems[0].Tag;
         }
         _controler.SelectCurrentTask(selectedTask);
     }
 }