Esempio n. 1
0
        public async Task <IActionResult> Update([FromBody] TaskMaster.Models.Task task)
        {
            task.ModifiedDate = DateTime.Now;
            context.Update(task);

            var result = await context.SaveChangesAsync();

            return(Ok(result));
        }
Esempio n. 2
0
        public async Task <IActionResult> Save([FromBody] TaskMaster.Models.Task task)
        {
            var project = await context.Projects.Where(p => p.ID == task.ProjectId)
                          .SingleOrDefaultAsync();

            var existingTask = await context.Tasks
                               .OrderByDescending(t => t.CreatedDate)
                               .Where(t => t.ProjectId == task.ProjectId)
                               .Take(1)
                               .SingleOrDefaultAsync();

            string newTracker = "";

            if (existingTask != null)
            {
                var tracker   = existingTask.Tracker;;
                var trackers  = tracker.Split('-');
                var increment = Convert.ToInt32(trackers[1]) + 1;
                newTracker = trackers[0] + "-" + increment;
            }
            else
            {
                newTracker = project.Initial + "-1";
            }

            task.ID               = Guid.NewGuid();
            task.Tracker          = newTracker;
            task.CreatedDate      = DateTime.Now;
            task.Status           = "New";
            task.Estimation       = 1;
            task.EstimationUnit   = "d";
            task.EstimationInHour = 8;

            context.Add(task);
            var result = await context.SaveChangesAsync();

            return(Ok(result));
        }
Esempio n. 3
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtTask.Text))
            {
                MessageBox.Show("Please enter task before clicking Create button!");
                return;
            }
            if (cbStatuses.SelectedItem == null)
            {
                MessageBox.Show("Please select a status for the task!");
                return;
            }
            var dbContext = new tmDbContext();
            var status    = (cbStatuses.SelectedItem as Status);
            var newTask   = new Models.Task {
                Name = txtTask.Text, DueDate = dtDueDate.Value, StatusId = status.Id
            };

            dbContext.Tasks.Add(newTask);
            dbContext.SaveChanges();
            RefreshData();
            txtTask.Text = "";
        }