public static List<ProjectTask> DeleteProjectTask(ProjectTask PT)
 {
     var projectTask = (from projTasks in dataContext.ProjectTasks
                        where projTasks.ProjectTaskID == PT.ProjectTaskID
                        select projTasks).SingleOrDefault();
     dataContext.ProjectTasks.Remove(projectTask);
     dataContext.SaveChanges();
     return GetAllProjectTasks();
 }
 //Delete the Project on the basis of the projectID
 public static List<ProjectTask> DeleteProject(ProjectTask p)
 {
     var proj = (from projectTask in dataContext.ProjectTasks
                 where projectTask.ProjectTaskID == p.ProjectTaskID
                 select projectTask).SingleOrDefault();
     dataContext.ProjectTasks.Remove(proj);
     dataContext.SaveChanges();
     return GetAllProjectTasks();
 }
        public async Task Create(ProjectTask task, int TaskListId)
        {
            ApplicationUser user = _user.Get();

            task.TaskList = _tasklist.GetById(TaskListId);
            _context.ProjectTasks.Add(new ProjectTask {
                Name = task.Name, Description = task.Description, Author = user, TaskList = task.TaskList
            });
            await _context.SaveChangesAsync();
        }
Beispiel #4
0
        public ActionResult Comment(ProjectTask projectTask)
        {
            if (ModelState.IsValid)
            {
                TaskHelper.EditTask(projectTask);
                return(RedirectToAction("Index", "Manage"));
            }

            return(View(projectTask));
        }
        public static List <ProjectTask> DeleteProjectTask(ProjectTask PT)
        {
            var projectTask = (from projTasks in dataContext.ProjectTasks
                               where projTasks.ProjectTaskID == PT.ProjectTaskID
                               select projTasks).SingleOrDefault();

            dataContext.ProjectTasks.Remove(projectTask);
            dataContext.SaveChanges();
            return(GetAllProjectTasks());
        }
        public ActionResult EditTask(WorkItemViewModel model)
        {
            ProjectTask item = unitOfWork.WorkItemRepository.GetByID(model.Id);

            item.AssignedWorker = model.AssignedWorker;
            unitOfWork.WorkItemRepository.Update(item);
            unitOfWork.Save();

            return(RedirectToAction("Index"));
        }
        protected override Task Context()
        {
            sut = new ProjectTask(_workspace, _applicationController, _dialogCreator,
                                  _executionContext, new HeavyWorkManagerFailingForSpecs(), _workspaceLayoutUpdater, _userSettings, _journalTask, _journalRetriever, _snapshotTask, _buildingBlockInProjectManager);

            A.CallTo(() => _workspace.ProjectHasChanged).Returns(true);
            _project.FilePath = FileHelper.GenerateTemporaryFileName();
            A.CallTo(() => _dialogCreator.MessageBoxYesNoCancel(PKSimConstants.UI.SaveProjectChanges, ViewResult.Yes)).Returns(ViewResult.Yes);
            return(_completed);
        }
        public async Task <ActionResult <TaskViewModel> > AddTaskToProjectAsync(ProjectTaskViewModel projectTaskViewModel)
        {
            if (projectTaskViewModel == null)
            {
                return(BadRequest("No valid ProjectTask received"));
            }
            if (projectTaskViewModel.ProjectId == Guid.Empty || projectTaskViewModel.TaskId == Guid.Empty)
            {
                return(BadRequest("Project and/or Task Ids cannot be empty"));
            }

            try
            {
                ProjectTask projectTask = ProjectTaskViewModel.CreateProjectTask(projectTaskViewModel);
                if (projectTask == null)
                {
                    return(BadRequest("Unable to convert ProjectTaskViewModel to ProjectTask"));
                }
                projectTask.Task    = (await taskService.GetTaskAsync(projectTask.TaskId)).Data;
                projectTask.Project = (await projectService.GetProjectDetailsAsync(projectTask.ProjectId)).Data;
                if (projectTask.Task == null || projectTask.Project == null)
                {
                    return(BadRequest("Unable to add project and or task to projecttask"));
                }

                string oid = IdentityHelper.GetOid(HttpContext.User.Identity as ClaimsIdentity);
                projectTask.LastEditBy = oid;

                TaskResult <ProjectTask> result;
                if (projectTask.Id == Guid.Empty)
                {
                    result = await taskService.AddTaskToProjectAsync(projectTask);
                }
                else
                {
                    return(BadRequest("Cannot update existing ProjectTask with post method"));
                }

                if (!result.Succeeded)
                {
                    return(UnprocessableEntity(new ErrorViewModel {
                        Type = Type.Error, Message = result.Message
                    }));
                }
                return(Ok(TaskViewModel.CreateVm(result.Data.Task)));
            }
            catch (Exception ex)
            {
                string message = GetType().Name + "Error in " + nameof(AddTaskToProjectAsync);
                logger.LogError(ex, message);
                return(UnprocessableEntity(new ErrorViewModel {
                    Type = Type.Error, Message = message
                }));
            }
        }
 public ActionResult Edit([Bind(Include = "Id,Name,ProjectId,PercentageCompleted,Priority,Duedate,Completed")] ProjectTask projectTask)
 {
     if (ModelState.IsValid)
     {
         db.Entry(projectTask).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ProjectId = new SelectList(db.Projects, "Id", "Name", projectTask.ProjectId);
     return(View(projectTask));
 }
Beispiel #10
0
        public async Task <IActionResult> EditProjectTask(long projectTaskId, [FromBody] ProjectTask projectTask)
        {
            var oldProjectTask = await _dbContext.ProjectTasks.SingleAsync(q => q.Id == projectTaskId);

            oldProjectTask.ProjectTaskStatus = projectTask.ProjectTaskStatus;
            oldProjectTask.Description       = projectTask.Description;

            await _dbContext.SaveChangesAsync();

            return(NoContent());
        }
        public void WhenAddAChildTaskToATaskThenItHasOneChildTask()
        {
            ProjectTask task  = CreateTask();
            ProjectTask child = AddProjectTask(task);

            IEnumerable <ProjectTask> children = task.Tasks;
            ProjectTask firstChild             = children.First();

            Assert.That(children.Count(), Is.EqualTo(1));
            Assert.That(firstChild, Is.SameAs(child));
        }
        public FileResult DownloadTaskData(int id)
        {
            OPTDBContext context       = new OPTDBContext();
            ProjectTask  projectTaskDB = context.ProjectTasks.FirstOrDefault(pt => pt.ProjectTaskID == id);
            string       fileName      = projectTaskDB.TaskData;
            string       path          = Server.MapPath("~/Content/Uploads/" + fileName);

            byte[] fileBytes = System.IO.File.ReadAllBytes(path);
            return(File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName));
            //return File(path, System.Net.Mime.MediaTypeNames.Application.Octet, fileName);
        }
        public async Task <IActionResult> DefineNewProjectTasks(long projectId, [FromBody] ProjectTask task)
        {
            task.ProjectId  = projectId;
            task.Project    = null;
            task.AssigneeId = task.Assignee.Id;
            task.Assignee   = null;
            _dbContext.Add(task);
            await _dbContext.SaveChangesAsync();

            return(NoContent());
        }
Beispiel #14
0
        public bool Create(ProjectTask data)
        {
            Employee employee = _context.Employees.First(row => row.Id == data.Employee.Id);
            Project  project  = _context.Projects.First(row => row.Id == data.Project.Id);

            data.Employee = employee;
            data.Project  = project;
            _context.Tasks.Add(data);
            _context.SaveChanges();
            return(true);
        }
Beispiel #15
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void View_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == System.Windows.Forms.MouseButtons.Right)
     {
         if (View.SelectedItems.Count == 1)
         {
             ProjectTask ATask = (ProjectTask)View.SelectedItems[0].Tag;
             Menu.Show(Cursor.Position);
         }
     }
 }
 public void SetTask(ProjectTask task)
 {
     EditingTask = task;
     if (Task != null)
     {
         Task.ErrorsChanged -= RaiseCanExecuteChanged;
     }
     Task = new EditableTask();
     Task.ErrorsChanged += RaiseCanExecuteChanged;
     CopyTask(task, Task);
 }
Beispiel #17
0
        internal static ProjectTask gettask(HttpResponseMessage responce)
        {
            var task    = new ProjectTask();
            var jsonObj = JsonConvert.DeserializeObject <Dictionary <string, object> >(responce.Content.ReadAsStringAsync().Result);

            if (jsonObj.ContainsKey("task"))
            {
                task = JsonConvert.DeserializeObject <ProjectTask>(jsonObj["task"].ToString());
            }
            return(task);
        }
Beispiel #18
0
        /// <summary>
        ///     Updates the details of a task.
        /// </summary>
        /// <param name="project_id">The project_id is the idntifier of the project.</param>
        /// <param name="task_id">The task_id is the identifier of the task of specified project.</param>
        /// <param name="update_info">The update_info is the ProjectTask object which contains the updation information.</param>
        /// <returns>ProjectTask object.</returns>
        public ProjectTask UpdateTask(string project_id, string task_id, ProjectTask update_info)
        {
            var url        = baseAddress + "/" + project_id + "/tasks/" + task_id;
            var json       = JsonConvert.SerializeObject(update_info);
            var jsonstring = new Dictionary <object, object>();

            jsonstring.Add("JSONString", json);
            var responce = ZohoHttpClient.put(url, getQueryParameters(jsonstring));

            return(ProjectParser.gettask(responce));
        }
        public void WhenAddATaskThenTheProjectHasOneTask()
        {
            Project project = CreateProjectWithDefaultNameAndDefaultCalendar();

            ProjectTask task = AddProjectTask(project);
            IEnumerable <ProjectTask> tasks = project.Tasks;
            ProjectTask firstTask           = tasks.First();

            Assert.That(tasks.Count(), Is.EqualTo(1));
            Assert.That(firstTask, Is.SameAs(task));
        }
Beispiel #20
0
        private async Task removeTaskWithChildren(ProjectTask task)
        {
            //should do better - build up list of ids to remove, then remove them in one query
            var tasks = await _context.Tasks.Where(p => p.ParentId == task.Id).ToListAsync();

            foreach (var ctask in tasks)
            {
                await removeTaskWithChildren(ctask);
            }
            _context.Tasks.Remove(task);
        }
Beispiel #21
0
 public ActionResult Edit([Bind(Include = "ID,Name,ProjectID")] ProjectTask projectTask)
 {
     if (ModelState.IsValid)
     {
         db.Entry(projectTask).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ProjectID = new SelectList(db.Projects, "ID", "Name", projectTask.ProjectID);
     return(View(projectTask));
 }
        public IHttpActionResult GetProjectTask(int id)
        {
            ProjectTask projectTask = db.ProjectTasks.Find(id);

            if (projectTask == null)
            {
                return(NotFound());
            }

            return(Ok(projectTask));
        }
        public PartialViewResult Side(string projectName, ProjectTask model, int?idPr)
        {
            ViewBag.proName = projectName;
            var us     = _repositoryAppUser.Find(u => u.Email.Equals(User.Identity.Name));
            var user   = us.FirstOrDefault();
            var groups = _repositoryProject.GetAllForMe(user);

            ViewBag.All = groups;
            ViewBag.Id  = idPr;
            return(PartialView(model));
        }
 public ActionResult Edit([Bind(Include = "ProjectTaskID,Description,EstimatedPomodoroCount,ProjectID")] ProjectTask projectTask)
 {
     if (ModelState.IsValid)
     {
         db.Entry(projectTask).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Details", "Projects", new { id = projectTask.ProjectID }));
     }
     ViewBag.ProjectID = new SelectList(db.Projects, "ProjectID", "Description", projectTask.ProjectID);
     return(View(projectTask));
 }
Beispiel #25
0
        public async Task <IHttpActionResult> GetProjectTask(int id)
        {
            ProjectTask projectTask = await db.Tasks.FindAsync(id);

            if (projectTask == null)
            {
                return(NotFound());
            }

            return(Ok(projectTask));
        }
Beispiel #26
0
        /// <summary>
        /// Создание письма о новой задаче для пользователя
        /// </summary>
        public async Task CreateMailForNewPerformerAsync(User user, ProjectTask projectTask)
        {
            if (projectTask == null || user == null)
            {
                return;
            }

            await _context.Mails.AddAsync(GetMailForPerformer(user, projectTask));

            await _context.SaveChangesAsync();
        }
        public ProjectTask RemoveProjectTask(long taskId) // Return null for any errors otherwise ProjectTask
        {
            ProjectTask pTask = ProjectToDos.Where(pt => pt.TaskId == taskId).FirstOrDefault();

            if (pTask != null)
            {
                context.ProjectTask.Remove(pTask);
                context.SaveChanges();
            }
            return(pTask);
        }
 public IHttpActionResult Put(ProjectTask p)
 {
     var prjTasks = ProjectTasksRepository.UpdateProject(p);
     if (prjTasks != null)
     {
         return Ok(prjTasks);
     }
     else
     {
         return NotFound();
     }
 }
Beispiel #29
0
 public ReportManager(string taskId, string reportId, string projectId)
 {
     _taskId         = taskId;
     _reportId       = reportId;
     _projectId      = projectId;
     _currentProject = RepositoryContext.Current.GetOne <Project>(p => p._id == _projectId);
     _currentTask    = _currentProject.Tasks.Find(t => t._id == _taskId);
     if (_currentTask.TaskReport == null || !_currentTask.TaskReport.Any())
     {
         _currentTask.TaskReport = new List <Report>();
     }
 }
Beispiel #30
0
        public async Task <IActionResult> taskDetails([FromBody] DetailsTaskInput detailsTaskInput)
        {
            string token = HttpContext.Request.Headers["Authorization"];

            if (token != null)
            {
                try
                {
                    Guid taskIDAsGuid     = new Guid(detailsTaskInput.TaskID);
                    DetailsTaskOutput DTO = new DetailsTaskOutput();


                    ProjectTask task = await _context.ProjectTasks.SingleOrDefaultAsync(x => x.ID == taskIDAsGuid);

                    if (task == null)
                    {
                        return(NotFound());
                    }

                    ApplicationUser user = await _userManager.FindByEmailAsync(_jwtService.GetClaimValue(token, "email"));

                    //Gets all the users on the task
                    List <Guid> userIDs = await _context.ProjectTaskUsers.Where(UT => UT.ProjectTaskID == taskIDAsGuid).Select(UT => UT.UserID).ToListAsync();

                    List <ApplicationUser> UsersOnTask = await _context.Users.ToListAsync();

                    UsersOnTask     = UsersOnTask.Where(u => userIDs.Contains(u.Id)).ToList();
                    DTO.UsersOnTask = new List <UserOutput>();
                    UsersOnTask.ForEach(u =>
                    {
                        UserOutput UO = new UserOutput();
                        UO.Username   = u.UserName;
                        UO.Email      = u.Email;
                        UO.Avatar     = "https://www.suitdoctors.com/wp-content/uploads/2016/11/dummy-man-570x570.png";
                        DTO.UsersOnTask.Add(UO);
                    });

                    DTO.Remarks = await _context.Remarks.Where(Remark => Remark.ProjectTaskID == taskIDAsGuid).ToListAsync();

                    DTO.Remarks = DTO.Remarks.OrderBy(x => x.Created).ToList();
                    return(Json(DTO));
                }
                catch (ApplicationException e)
                {
                    return(Unauthorized());
                }
                catch (Exception e)
                {
                    return(NotFound());
                }
            }
            return(Unauthorized());
        }
Beispiel #31
0
        public static List <ProjectTask> UpdateProjectTask(ProjectTask PT)
        {
            var projTask = (from projectTasks in dataContext.ProjectTasks where projectTasks.ProjectTaskId == PT.ProjectTaskId select projectTasks).SingleOrDefault( );

            projTask.AssignedTo     = PT.AssignedTo;
            projTask.TaskStartDate  = PT.TaskStartDate;
            projTask.TaskEndDate    = PT.TaskEndDate;
            projTask.TaskCompletion = PT.TaskCompletion;
            projTask.USerStoryID    = PT.USerStoryID;
            dataContext.SaveChanges( );
            return(GetAllProjectTasks( ));
        }
Beispiel #32
0
        public ActionResult Create([Bind(Include = "ID,Name,ProjectID")] ProjectTask projectTask)
        {
            if (ModelState.IsValid)
            {
                db.ProjectTasks.Add(projectTask);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ProjectID = new SelectList(db.Projects, "ID", "Name", projectTask.ProjectID);
            return(View(projectTask));
        }
 public void Setup()
 {
     testId            = Guid.NewGuid();
     testTitle         = "Build the barn";
     testCompletedTime = DateTime.Parse("2018-01-01");
     getsTaskUser      = Guid.NewGuid();
     losesTaskUser     = Guid.NewGuid();
     finalUser         = Guid.NewGuid();
     testTask1         = new ProjectTask {
         Title = "Buy Boards", Description = "Get 26 2x4s", Status = TaskStatus.UnStarted, Id = 1, AssignedToUser = losesTaskUser
     };
 }
 public static List<ProjectTask> UpdateProjectTask(ProjectTask PT)
 {
     var projectTask = (from projTasks in dataContext.ProjectTasks
                        where projTasks.ProjectTaskID == PT.ProjectTaskID
                        select projTasks).SingleOrDefault();
     projectTask.AssignedTo = PT.AssignedTo;
     projectTask.TaskStartDate = PT.TaskStartDate;
     projectTask.TaskEndDate = PT.TaskEndDate;
     projectTask.TaskCompletion = PT.TaskCompletion;
     projectTask.UserStoryID = PT.UserStoryID;
     dataContext.SaveChanges();
     return GetAllProjectTasks();
 }
        //Update the Project  on the basis of the projectID
        public static List<ProjectTask> UpdateProject(ProjectTask p)
        {
            //get the details of the project
            var proj = (from projectTask in dataContext.ProjectTasks
                        where projectTask.ProjectTaskID == p.ProjectTaskID
                        select projectTask).SingleOrDefault();

            proj.AssignedTo = p.AssignedTo;
            proj.TaskStartDate = p.TaskStartDate;
            proj.TaskEndDate = p.TaskEndDate;
            proj.TaskCompletion = p.TaskCompletion;
            proj.UserStoryID = p.UserStoryID;
            dataContext.SaveChanges();
            return GetAllProjectTasks();
        }
 public static ProjectTask CreateFromClientToServer(this ProjectTask source, ProjectTask projectTask)
 {
     source.TaskId = projectTask.TaskId;
     source.ProjectId = projectTask.ProjectId;
     source.CustomerId = projectTask.CustomerId;
     source.TaskNameE = projectTask.TaskNameE;
     source.TaskNameA = projectTask.TaskNameA;
     source.DescriptionE = projectTask.DescriptionE;
     source.DescriptionA = projectTask.DescriptionA;
     source.StartDate = projectTask.StartDate;
     source.EndDate = projectTask.EndDate;
     source.TotalCost = projectTask.TotalCost;
     source.TotalWeight = projectTask.TotalWeight;
     source.TaskProgress = projectTask.TaskProgress;
     source.NotesE = projectTask.NotesE;
     source.NotesA = projectTask.NotesA;
     source.RecCreatedBy = projectTask.RecCreatedBy;
     source.RecCreatedDt = projectTask.RecCreatedDt;
     source.RecLastUpdatedBy = projectTask.RecLastUpdatedBy;
     source.RecLastUpdatedDt = projectTask.RecLastUpdatedDt;
     return source;
 }
 public static ProjectTask CreateFromClientToServer(this Models.ProjectTask source)
 {
     ProjectTask projectTask = new ProjectTask();
     projectTask.TaskId = source.TaskId;
     projectTask.ProjectId = source.ProjectId;
     projectTask.CustomerId = source.CustomerId;
     projectTask.TaskNameE = source.TaskNameE;
     projectTask.TaskNameA = source.TaskNameA;
     projectTask.DescriptionE = source.DescriptionE;
     projectTask.DescriptionA = source.DescriptionA;
     projectTask.StartDate = source.StartDate == null ? (DateTime?)null : DateTime.ParseExact(source.StartDate, "dd/MM/yyyy", new CultureInfo("en"));
     projectTask.EndDate = source.EndDate == null ? (DateTime?)null : DateTime.ParseExact(source.EndDate, "dd/MM/yyyy", new CultureInfo("en"));
     projectTask.TotalCost = source.TotalCost;
     projectTask.TotalWeight = source.TotalWeight;
     projectTask.TaskProgress = source.TaskProgress;
     projectTask.NotesE = source.NotesE;
     projectTask.NotesA = source.NotesA;
     projectTask.RecCreatedBy = source.RecCreatedBy;
     projectTask.RecCreatedDt = source.RecCreatedDt;
     projectTask.RecLastUpdatedBy = source.RecLastUpdatedBy;
     projectTask.RecLastUpdatedDt = source.RecLastUpdatedDt;
     projectTask.PreRequisitTask = source.RequisitTasks.Select(x=>x.CreateFromClientToServer()).ToList();
     return projectTask;
 }
 public static ProjectTask CreateProjectTask(int ID, string title, global::System.DateTime dueDate, string priority, string status, decimal percentCompleted, int projectTask_Project, byte[] rowVersion)
 {
     ProjectTask projectTask = new ProjectTask();
     projectTask.Id = ID;
     projectTask.Title = title;
     projectTask.DueDate = dueDate;
     projectTask.Priority = priority;
     projectTask.Status = status;
     projectTask.PercentCompleted = percentCompleted;
     projectTask.ProjectTask_Project = projectTask_Project;
     projectTask.RowVersion = rowVersion;
     return projectTask;
 }
 public IEnumerable<ProjectTask> Delete(ProjectTask pt)
 {
     return ProjectTasksRepository.DeleteProjectTask(pt);
 }
 public IEnumerable<ProjectTask> Post(ProjectTask pt)
 {
     return ProjectTasksRepository.InsertProjectTask(pt);
 }
 public IEnumerable<ProjectTask> Put(ProjectTask pt)
 {
     return ProjectTasksRepository.UpdateProjectTask(pt);
 }
Beispiel #42
0
        public void ProcessAction(RefreshProjectTasksCommand eventObject)
        {
            var tasks = this.taskRepository.FindAll();

            var project = this.projectRepository.FindById(eventObject.ProjectId);

            var tasksByOriginalId = new Dictionary<int, ProjectTask>();
            foreach(var item in project.Tasks)
            {
                tasksByOriginalId.Add(item.TaskId, item);
            }

            // maj de l'existant
            var toAdd = new List<ProjectTask>();
            foreach(var item in tasks)
            {
                ProjectTask projectTask;
                if(tasksByOriginalId.TryGetValue(item.Id, out projectTask))
                {
                    projectTask.Name = item.Name;
                    projectTask.Category = item.Category;
                    projectTask.Type = item.Type;
                    projectTask.OrderId = item.OrderId;
                }
                else
                {
                    projectTask = new ProjectTask
                                      {
                                          Name = item.Name,
                                          TaskId = item.Id,
                                          Category = item.Category,
                                          Type = item.Type,
                                          OrderId = item.OrderId
                                      };
                    project.Tasks.Add(projectTask);
                    toAdd.Add(projectTask);
                }
            }

            // suppressions de ceux qui n'existent plus
            var toRemove = new List<ProjectTask>();
            foreach(var item in project.Tasks)
            {
                var task = tasks.Where(x => x.Id == item.TaskId).FirstOrDefault();
                if(task == null)
                {
                    toRemove.Add(item);
                }
            }
            foreach(var item in toRemove)
            {
                project.Tasks.Remove(item);
                foreach(var hardware in project.Hardwares)
                {
                    var existing = hardware.Tasks.Where(x => x.Task.TaskId == item.TaskId).FirstOrDefault();
                    if(existing != null)
                    {
                        hardware.Tasks.Remove(existing);
                    }
                }
            }

            this.projectRepository.Save(project);
            this.eventBroker.Publish(new ProjectUpdatedEvent(project.Id), Topics.EVENTS);
        }
 public void AddToProjectTasks(ProjectTask projectTask)
 {
     base.AddObject("ProjectTasks", projectTask);
 }
 //Insert Project
 public static List<ProjectTask> InsertProjectTask(ProjectTask p)
 {
     dataContext.ProjectTasks.Add(p);
     dataContext.SaveChanges();
     return GetAllProjectTasks();
 }