예제 #1
0
        public async Task <bool> EditTask(Taskz tasks)
        {
            var task = await _context.Tasks.FindAsync(tasks.Id);


            task.Description = tasks.Description;
            task.Name        = tasks.Name;
            task.LastUpdate  = DateTime.UtcNow;

            _context.Entry(task).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(true);
        }
예제 #2
0
        public async Task <Taskz> GetTasksById(int id)
        {
            var data = await _context.Tasks.FindAsync(id);

            var data1 = new Taskz
            {
                Id          = data.Id,
                Name        = data.Name,
                Description = data.Description,
                StartDate   = data.StartDate,
                EndDate     = data.EndDate,
                EmployeeId  = data.EmployeesId,
                projectId   = data.ProjectsId,
                CreatedDate = data.CreatedDate,
                LastUpdate  = data.LastUpdate
            };

            return(data1);
        }
예제 #3
0
        public async Task <int> AddTask(Taskz Task)
        {
            var employee = await _context.Employees.FindAsync(Task.EmployeeId);

            var project = await _context.Projects.FindAsync(Task.projectId);

            int id   = Int16.Parse(Task.Name);
            var task = await _context.PreSalesTasks.FindAsync(id);

            var NewTask = new Tasks
            {
                Description      = Task.Description,
                Name             = task.Description,
                StartDate        = Task.StartDate,
                EndDate          = Task.EndDate,
                ProjectsId       = Task.projectId,
                CreatedDate      = DateTime.UtcNow,
                LastUpdate       = DateTime.UtcNow,
                EmployeesId      = Task.EmployeeId,
                EmployeeName     = employee.EmpFName + " " + employee.EmpLName,
                ProjectName      = project.Name,
                ProjectManager   = Task.ProjectManager,
                ProjectManagerId = Task.ProjectManagerId,
                TimeSheet        = false
            };

            task.IsAssigned               = true;
            _context.Entry(task).State    = EntityState.Modified;
            project.AllocatedTasks        = project.AllocatedTasks + 1;
            _context.Entry(project).State = EntityState.Modified;
            await _context.Tasks.AddAsync(NewTask);

            await _context.SaveChangesAsync();

            return(NewTask.Id);
        }