Esempio n. 1
0
        public DboProject EditProject(Project project)
        {
            List <ProjectSkills> projectSkills = context.ProjectSkills.Where(ps => ps.ProjectId == project.Id).ToList();

            context.ProjectSkills.RemoveRange(projectSkills);
            context.SaveChanges();

            Project projectToEdit = FindProjectById(project.Id);

            projectToEdit.Company      = project.Company;
            projectToEdit.CurrentHours = project.CurrentHours;
            projectToEdit.EmployeeProjectHourPerWeeks = project.EmployeeProjectHourPerWeeks;
            projectToEdit.Name          = project.Name;
            projectToEdit.NumberOfWeeks = project.NumberOfWeeks;
            projectToEdit.PlannedHours  = project.PlannedHours;
            projectToEdit.ProjectLeader = employeeServices.FindEmployeeById(project.ProjectLeader.Id);
            projectToEdit.Risk          = project.Risk;
            projectToEdit.StartDate     = project.StartDate;
            projectToEdit.DueDate       = project.DueDate;
            projectToEdit.ProjectSkills = project.ProjectSkills;
            context.SaveChanges();

            DboProject dboProject = (DboProject)projectToEdit;

            dboProject.Skills = skillServices.GetSkillsForProject(projectToEdit.Id);
            return(dboProject);
        }
Esempio n. 2
0
        public DboProject CreateProject(Project project)
        {
            project.ProjectLeader = employeeServices.FindEmployeeById(project.ProjectLeader.Id);
            project.NumberOfWeeks = HelperServices.GetWeekOfYear(project.DueDate) - HelperServices.GetWeekOfYear(project.StartDate);
            context.Projects.Add(project);
            context.SaveChanges();

            List <DboSkill> skills = new List <DboSkill>();

            foreach (var item in project.ProjectSkills)
            {
                Skill    skill    = context.Skills.Where(s => s.Id == item.SkillId).FirstOrDefault();
                DboSkill dboSkill = new DboSkill()
                {
                    Id   = skill.Id,
                    Name = skill.Name
                };

                skills.Add(dboSkill);
            }

            DboProject dboProject = (DboProject)project;

            dboProject.Skills = skills;

            return(dboProject);
        }
Esempio n. 3
0
        public List <DboProject> GetProjects()
        {
            List <Project>    projects    = context.Projects.Include(p => p.ProjectLeader).ToList();
            List <DboProject> dboProjects = new List <DboProject>();

            foreach (var item in projects)
            {
                DboProject dboProject = (DboProject)item;
                dboProject.Skills = skillServices.GetSkillsForProject(item.Id);
                dboProjects.Add(dboProject);
            }

            return(dboProjects);
        }