public async Task <ActionResult> Edit([Bind(Include = "Id,BacklogItemId,Title,Description,EstimatedTime,RemainingTime,SprintId,UserId,CreationDate,TaskStateId")] DAL.Task task) { try { if (ModelState.IsValid) { db.Entry(task).State = EntityState.Modified; await db.SaveChangesAsync(); await db.Entry(task).ReloadAsync(); var backlogItem = await db.BacklogItems.FindAsync(task.BacklogItemId); backlogItem.Title = task.Title; backlogItem.Description = task.Description; db.Entry(backlogItem).State = EntityState.Modified; await db.SaveChangesAsync(); return(PartialView("_EditSuccessfulModal", task)); } } catch { ModelState.AddModelError(String.Empty, "Error en DB o excepción");//TODO Eliminar cuando estén las validaciones } var sprints = await db.Sprints .Where(s => !s.Erased && s.ProjectId == SelectedProjectId) .ToListAsync(); ViewBag.SprintId = new SelectList(sprints, "Id", "Name", task.SprintId); var team = await db.Teams .Include(t => t.TeamMembers) .Include("TeamMembers.User") .FirstOrDefaultAsync(t => !t.Erased && t.ProjectId == SelectedProjectId); List <User> users = new List <User>(); if (team != null) { users = team.TeamMembers .Where(m => !m.Erased) .Select(tm => tm.User).ToList(); } ViewBag.UserId = new SelectList(users, "Id", "FullName", task.UserId); return(PartialView("_EditModal", task)); }
private void btnSave_Click(object sender, EventArgs e) { if (task.EmployeeID == 0) { MessageBox.Show("Select an Employee"); } else if (txtTitle.Text.Trim() == "") { MessageBox.Show("Add a Task"); } else if (txtContent.Text.Trim() == "") { MessageBox.Show("Add Content"); } else { if (!isUpdate) { task.TaskTitle = txtTitle.Text; task.TaskContent = txtContent.Text; task.TaskStartDate = DateTime.Today; task.TaskState = 1; TaskBLL.AddTask(task); MessageBox.Show("Task added"); txtTitle.Clear(); txtContent.Clear(); task = new DAL.Task(); } else if (isUpdate) { DialogResult result = MessageBox.Show("Are yu sure?", "Warning", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { DAL.Task update = new DAL.Task(); update.ID = DETAIL.TaskID; if (Convert.ToInt32(txtUserNo.Text) != DETAIL.UserNo) { update.EmployeeID = task.EmployeeID; } else { update.EmployeeID = DETAIL.EmployeeID; } update.TaskTitle = txtTitle.Text; update.TaskContent = txtContent.Text; update.TaskState = Convert.ToInt32(cmbTaskState.SelectedValue); TaskBLL.UpdateTask(update); MessageBox.Show("The task was updated"); this.Close(); } } } }
public async Task <ActionResult> DeleteConfirmed(int id) { DAL.Task task = await db.Tasks.FindAsync(id); task.Erased = true; db.Entry(task).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (Exception ex) { } return(RedirectToAction("Index", "Change")); }
// GET: /Change/Delete/5 public async Task <ActionResult> Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DAL.Task task = await db.Tasks.FindAsync(id); if (task == null) { return(HttpNotFound()); } base.ValidateCompany(task); return(View(task)); }
public async Task <JsonResult> DeleteAjax(int?id) { DAL.Task task = await db.Tasks.FindAsync(id); task.Erased = true; if (task.BacklogItem is Test) { task.BacklogItem.Erased = true; } db.Entry(task).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (Exception ex) { } return(Json(true)); }
public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DAL.Task task = await db.Tasks.FindAsync(id); if (task == null) { return(HttpNotFound()); } var sprints = await db.Sprints .Where(s => !s.Erased && s.ProjectId == SelectedProjectId) .ToListAsync(); ViewBag.SprintId = new SelectList(sprints, "Id", "Name", task.SprintId); var team = await db.Teams .Include(t => t.TeamMembers) .Include("TeamMembers.User") .FirstOrDefaultAsync(t => !t.Erased && t.ProjectId == SelectedProjectId); List <User> users = new List <User>(); if (team != null) { users = team.TeamMembers .Where(m => !m.Erased) .Select(tm => tm.User).ToList(); } ViewBag.UserId = new SelectList(users, "Id", "FullName", task.UserId); return(PartialView("_EditModal", task)); }
// // GET: /Task/ public async Task <PartialViewResult> Create(int?id) { var parentId = id ?? 0; var task = new DAL.Task { BacklogItemId = parentId, CreationDate = DateTime.Now, TaskStateId = (int)TaskStateEnum.ToDo }; var sprints = await db.Sprints .Where(s => !s.Erased && s.ProjectId == SelectedProjectId) .ToListAsync(); ViewBag.SprintId = new SelectList(sprints, "Id", "Name"); var team = await db.Teams .Include(t => t.TeamMembers) .Include("TeamMembers.User") .FirstOrDefaultAsync(t => !t.Erased && t.ProjectId == SelectedProjectId); List <User> users = new List <User>(); if (team != null) { users = team.TeamMembers .Where(m => !m.Erased) .Select(tm => tm.User).ToList(); } ViewBag.UserId = new SelectList(users, "Id", "FullName"); return(PartialView("_CreateModal", task)); }