public ActionResult Create(Employee newEmployee)
        {
            try
            {
                ViewBag.Projects = new MultiSelectList(_employeeService.GetAllProjects(), "ProjectId", "ProjectName");
                ViewBag.Skills = new MultiSelectList(_employeeService.GetAllSkillSets(), "SkillSetId", "Name");
           
                // TODO: Add insert logic here
                if (newEmployee.ProjectId != null)
                {
                    foreach (int projectId in newEmployee.ProjectId)
                    {
                        var employeeProject = _employeeService.GetProjectById(projectId);
                        newEmployee.Projects.Add(employeeProject);
                    }
                }
                if (newEmployee.SkillId != null)
                {
                    foreach (int skillId in newEmployee.SkillId)
                    {
                        var employeeSkill = _employeeService.GetSkillSetById(skillId);
                        newEmployee.SkillSets.Add(employeeSkill);
                    }
                }

                _employeeService.SaveEmployee(newEmployee);
                ViewBag.SavedEmployee = newEmployee.FirstName;
                return View("Success");
            }
            catch
            {
                return View();
            }

        }
예제 #2
0
 public void SaveEmployee(Employee newEmployee)
 {
     if (newEmployee.ProjectId != null)
     {
         foreach (int projectId in newEmployee.ProjectId)
         {
             var employeeProject = GetProjectById(projectId);
             newEmployee.Projects.Add(employeeProject);
         }
     }
     if (newEmployee.SkillId != null)
     {
         foreach (int skillId in newEmployee.SkillId)
         {
             var employeeSkill = GetSkillSetById(skillId);
             newEmployee.SkillSets.Add(employeeSkill);
         }
     }
     foreach (var project in newEmployee.Projects)
     {
         context.Attach<Project>(project);
     }
     foreach (var skill in newEmployee.SkillSets)
     {
         context.Attach<SkillSet>(skill);
     }
     context.Add<Employee>(newEmployee);
 }
 public ActionResult Create()
 {
     var newEmployee = new Employee();
     ViewBag.Projects = new MultiSelectList(_employeeService.GetAllProjects(), "ProjectId", "ProjectName");
     ViewBag.Skills = new MultiSelectList(_employeeService.GetAllSkillSets(), "SkillSetId", "Name");
     return View(newEmployee);
 }
        public void EditEmployee(Employee selectedEmployee)
        {
            Employee emp = GetEmployeeById(selectedEmployee.EmployeeId);
            selectedEmployee.ContactId = emp.ContactId;
            selectedEmployee.Contact = emp.Contact;
            selectedEmployee.CubicleLocationId = emp.CubicleLocationId;
            selectedEmployee.CubicleLocation = emp.CubicleLocation;
           
            context.Update<Employee>(selectedEmployee);

          
        }
        public ActionResult Create(Employee newEmployee)
        {
            
            try
            {
                ViewData["Projects"] = new MultiSelectList(_employeeService.GetAllProjects(), "ProjectId", "ProjectName");
                ViewData["Skills"] = new MultiSelectList(_employeeService.GetAllSkillSets(), "SkillSetId", "Name");
                
           
                // TODO: Add insert logic here
              
                _employeeService.SaveEmployee(newEmployee);
                ViewBag.SavedEmployee = newEmployee.FirstName;
                return View("Success");
            }
            catch
            {
                return View("Error");
            }

        }
 public void SaveEmployee(Employee newEmployee)
 {
     context.Add(newEmployee);
 }
        public void Seed(FinderIpDataContext context)
           {
            const string roleAdmin = "Admin";
            const string roleManager = "Manager";
            const string roleUser = "******";

            // Since the initializer is specified through web.config
            // not able to inject UserManager here.
            // TODO: Find a way to inject it.
            var userManager = new UserManager();

            // Create role in identity DB.
            userManager.CreateIdentityRoleIfNotExist(roleAdmin);
            userManager.CreateIdentityRoleIfNotExist(roleManager);
            userManager.CreateIdentityRoleIfNotExist(roleUser);

            // Create users in identity DB.
            var adminMembershipId = userManager.CreateUserIfNotExist("*****@*****.**", "Testadmin@123");
            var managerMembershipId = userManager.CreateUserIfNotExist("*****@*****.**", "Testmanager@123");
            var userMembershipId = userManager.CreateUserIfNotExist("*****@*****.**", "Testuser@123");

            // Assign role to users.
            userManager.AssignRoleToUser(adminMembershipId, roleAdmin);
            userManager.AssignRoleToUser(managerMembershipId, roleManager);
            userManager.AssignRoleToUser(userMembershipId, roleUser);

            // Child object for an employee
            var contactForAdmin = new Contact
                {
                ContactId = 123,
                EmailAddress = "*****@*****.**",
                        MobileNumber = 758738,
                        PhoneNumber = "02382-265234",
                Skype = "sbirthare"
            };

            context.Add(contactForAdmin);

            var cubicleLocationForAdmin = new CubicleLocation
                    {
                CubicleLocationId = 234,
                        Building = "B",
                        DeskNumber = "5/INCB-14",
                        FloorNumber = 5
            };

            context.Add(cubicleLocationForAdmin);

            var adminUser = new Employee
            {
                EmployeeCode = "P3870",
                Contact = contactForAdmin,
                CubicleLocation = cubicleLocationForAdmin,
                EmployeeType = EmployeeType.Permanent,
                FirstName = "Shailendra",
                LastName = "Birthare",
                    HighestQualification = "B.E.",
                    ManagerRecommendation = "Well performance",
                SilicusExperienceInMonths = 12,
                TotalExperienceInMonths = 3,
                Gender = Gender.Male,
                MembershipId = adminMembershipId
            };

            context.Add(adminUser);

            // OLD DATA - NEED TO GO ONCE ABOVE WORK

            context.Add(new Employee
            {
                EmployeeCode = "P101",
                FirstName = "Shivani",
                MiddleName = "S.",
                LastName = "Surana",
                Gender = Gender.Male,
                Contact = new Contact
                {
                    EmailAddress = "*****@*****.**",
                    MobileNumber = 758439,
                    PhoneNumber = "02382-265236",
                    Skype = "ssurana"
                },
                CubicleLocation = new CubicleLocation
                {
                    Building = "B",
                    DeskNumber = "5/INCB-18",
                    FloorNumber = 5
                },
                //EmployeeSkillSets
                EmployeeType = EmployeeType.Permanent,
                HighestQualification = "C-DAC",
                ManagerRecommendation = "Well performance",
                SilicusExperienceInMonths = 4,
                TotalExperienceInMonths = 4,

                SkillSets = new List<SkillSet> 
                { 
                    new SkillSet {Name="ASP",Description="ASP.NET description" }
                },

                Projects = new List<Project> 
                {
                    new Project
                    {
                        ProjectName = "Silicus Lab",
                        Description = "Silicus Labs POCs",
                        ProjectType = ProjectType.Internal,
                        EngagementType = EngagementType.Fixed_Price,
                        StartDate = new DateTime(2015, 1, 10),
                        Status = Status.Not_Started,
                        ExpectedEndDate = new DateTime(2016, 2, 5),
                        ActualEndDate = new DateTime(2016, 6, 16),
                        EngagementManagerId = 5,
                        ProjectManagerId = 3,
                        AdditionalNotes = "Project is under consideration"
                    }
                },

                IsActive = true
            });

            context.Add(new Employee
            {
                EmployeeCode = "P102",
                FirstName = "Nikhil",
                MiddleName = "D.",
                LastName = "Darwai",
                Gender = Gender.Female,
                Contact = new Contact
                {
                    EmailAddress = "*****@*****.**",
                    MobileNumber = 758239,
                    PhoneNumber = "02382-265230",
                    Skype = "ndarwai"
                },
                CubicleLocation = new CubicleLocation
                {
                    Building = "B",
                    DeskNumber = "5/INCB-23",
                    FloorNumber = 5
                },
                //EmployeeSkillSets
                EmployeeType = EmployeeType.Permanent,
                HighestQualification = "C-DAC",
                ManagerRecommendation = "Well performance",
                SilicusExperienceInMonths = 4,
                TotalExperienceInMonths = 4,

                SkillSets = new List<SkillSet> 
                { 
                    new SkillSet {Name="Java",Description="Java description" }
                },

                Projects = new List<Project> 
                {
                    new Project
                    {
                        ProjectName = "Online Reservation",
                        Description = "All types of reservation",
                        ProjectType = ProjectType.External,
                        EngagementType = EngagementType.T_and_M,
                        StartDate = new DateTime(2014, 1, 10),
                        Status = Status.Completed,
                        ExpectedEndDate = new DateTime(2015, 10, 20),
                        ActualEndDate = new DateTime(2016, 1, 5),
                        EngagementManagerId = 1,
                        ProjectManagerId = 4,
                        AdditionalNotes = "Project is completed"
                    }
                },
                IsActive = true
            });


            context.Add(new Employee
            {
                EmployeeCode = "P103",
                FirstName = "Asha",
                MiddleName = "B.",
                LastName = "Bhandare",
                Gender = Gender.Female,
                Contact = new Contact
                {
                    EmailAddress = "*****@*****.**",
                    MobileNumber = 758126,
                    PhoneNumber = "02382-265229",
                    Skype = "abhandare"
                },
                CubicleLocation = new CubicleLocation
                {
                    Building = "B",
                    DeskNumber = "5/INCB-19",
                    FloorNumber = 5
                },
                //EmployeeSkillSets
                EmployeeType = EmployeeType.Contract,
                HighestQualification = "MBA",
                ManagerRecommendation = "Well performance",
                SilicusExperienceInMonths = 4,
                TotalExperienceInMonths = 4,

                SkillSets = new List<SkillSet> 
                { 
                    new SkillSet {Name="Python",Description="Python description" }
                },

                Projects = new List<Project> 
                {
                    new Project
                    {
                        ProjectName = "Frameworx",
                        Description = "Silicus internal .NET framework",
                        ProjectType = ProjectType.Internal,
                        EngagementType = EngagementType.Fixed_Price,
                        StartDate = new DateTime(2016, 1, 10),
                        Status = Status.In_Progress,
                        ExpectedEndDate = new DateTime(2016, 10, 20),
                        ActualEndDate = new DateTime(2016, 12, 4),
                        EngagementManagerId = 5,
                        ProjectManagerId = 3,
                        AdditionalNotes = "Project is under developement"
                    }
                },
                IsActive = true
            });


            context.Add(new Employee
            {
                EmployeeCode = "P104",
                FirstName = "Pratik",
                MiddleName = "P.",
                LastName = "Patil",
                Gender = Gender.Male,
                Contact = new Contact
                {
                    EmailAddress = "*****@*****.**",
                    MobileNumber = 758176,
                    PhoneNumber = "02382-124785",
                    Skype = "ppatil"
                },
                CubicleLocation = new CubicleLocation
                {
                    Building = "B",
                    DeskNumber = "5/INCB-20",
                    FloorNumber = 5
                },
                //EmployeeSkillSets
                EmployeeType = EmployeeType.Permanent,
                HighestQualification = "C-DAC",
                ManagerRecommendation = "Well performance",
                SilicusExperienceInMonths = 4,
                TotalExperienceInMonths = 4,

                SkillSets = new List<SkillSet> 
                { 
                    new SkillSet {Name="SalesForce",Description="SalesForce description" }
                },

                Projects = new List<Project> 
                {
                    new Project
                    {
                        ProjectName = "Provare",
                        Description = "Online tool for conducting tests",
                        ProjectType = ProjectType.External,
                        EngagementType = EngagementType.T_and_M,
                        StartDate = new DateTime(2015, 7, 8),
                        Status = Status.Completed,
                        ExpectedEndDate = new DateTime(2016, 2, 17),
                        ActualEndDate = new DateTime(2016, 5, 19),
                        EngagementManagerId = 2,
                        ProjectManagerId = 1,
                        AdditionalNotes = "Project is done"
                    }
                },
                IsActive = true
            });
        }
예제 #8
0
        public void EditEmployee(Employee selectedEmployee)
        {

            Employee targetEmployee = GetEmployeeById(selectedEmployee.EmployeeId);
            var employeeProjects = targetEmployee.Projects.ToList();
            var employeeSkills = targetEmployee.SkillSets.ToList();
            selectedEmployee.ContactId = targetEmployee.ContactId;
            selectedEmployee.Contact.ContactId = targetEmployee.Contact.ContactId;
            context.Update<Contact>(selectedEmployee.Contact);

            selectedEmployee.CubicleLocationId = targetEmployee.CubicleLocationId;
            selectedEmployee.CubicleLocation.CubicleLocationId = targetEmployee.CubicleLocation.CubicleLocationId;
            context.Update<CubicleLocation>(selectedEmployee.CubicleLocation);


            //context.Attach<Employee>(selectedEmployee);
            //if (selectedEmployee.ProjectId != null)
            //{
            //    foreach (int projectId in selectedEmployee.ProjectId)
            //    {
            //        var status = true;
            //        foreach (var project in employeeProjects)
            //        {
            //            if (project.ProjectId == projectId)
            //            {
            //                status = false;
            //                break;
            //            }
            //        }
            //        if (status)
            //        {
            //            var employeeProject = GetProjectById(projectId);
            //            context.Attach<Project>(employeeProject);
            //            selectedEmployee.Projects.Add(employeeProject);
            //        }

            //    }

            //}

            //context.Attach<Employee>(selectedEmployee);
            //if (selectedEmployee.SkillId != null)
            //{
            //    foreach (int skillId in selectedEmployee.SkillId)
            //    {
            //        var status = true;
            //        foreach (var skill in employeeSkills)
            //        {
            //            if (skill.SkillSetId == skillId)
            //            {
            //                status = false;
            //                break;
            //            }
            //        }
            //        if (status)
            //        {
            //            var employeeSkill = GetSkillSetById(skillId);
            //            context.Attach<SkillSet>(employeeSkill);
            //            selectedEmployee.SkillSets.Add(employeeSkill);
            //        }
            //    }
            //}

            context.Update<Employee>(selectedEmployee);          
            
        }
예제 #9
0
        public void AddProjectToEmployee(Employee selectedEmployee)
        {
            Employee targetEmployee = GetEmployeeById(selectedEmployee.EmployeeId);
            var employeeProjects = targetEmployee.Projects.ToList();
            var employeeSkills = targetEmployee.SkillSets.ToList();
            selectedEmployee.ContactId = targetEmployee.ContactId;
            selectedEmployee.Contact = targetEmployee.Contact;
            selectedEmployee.Contact.ContactId = targetEmployee.Contact.ContactId;
            context.Update<Contact>(selectedEmployee.Contact);

            selectedEmployee.CubicleLocationId = targetEmployee.CubicleLocationId;
            selectedEmployee.CubicleLocation = targetEmployee.CubicleLocation;
            selectedEmployee.CubicleLocation.CubicleLocationId = targetEmployee.CubicleLocation.CubicleLocationId;
            context.Update<CubicleLocation>(selectedEmployee.CubicleLocation);

            
            context.Attach<Employee>(selectedEmployee);
            if (selectedEmployee.ProjectId != null)
            {
                foreach (int projectId in selectedEmployee.ProjectId)
                {
                    var status = true;
                    foreach (var project in employeeProjects)
                    {
                        if (project.ProjectId == projectId)
                        {
                            status = false;
                            break;
                        }
                    }
                    if (status)
                    {
                        var employeeProject = GetProjectById(projectId);
                        context.Attach<Project>(employeeProject);
                        selectedEmployee.Projects.Add(employeeProject);
                    }

                }

            }
            context.Update<Employee>(selectedEmployee);  

        }
        public ActionResult Edit(Employee selectedEmployee)
        {
            ViewBag.Projects = new MultiSelectList(_employeeService.GetAllProjects(), "ProjectId", "ProjectName");
            ViewBag.Skills = new MultiSelectList(_employeeService.GetAllSkillSets(), "SkillSetId", "Name");
            try
            {
                if (selectedEmployee.ProjectId != null)
                {
                    foreach (int projectId in selectedEmployee.ProjectId)
                    {
                        var employeeProject = _employeeService.GetProjectById(projectId);
                        selectedEmployee.Projects.Add(employeeProject);
                    }
                }
                if (selectedEmployee.SkillId != null)
                {
                    foreach (int skillId in selectedEmployee.SkillId)
                    {
                        var employeeSkill = _employeeService.GetSkillSetById(skillId);
                        selectedEmployee.SkillSets.Add(employeeSkill);
                    }
                }
                _employeeService.EditEmployee(selectedEmployee);
                return View("Success");
            }
            catch
            {
                return View();
            }

        }
        public ActionResult AddSkillSetToEmployee(Employee selectedEmployee)
        {
            ViewData["Skills"] = new MultiSelectList(_employeeService.GetAllSkillSets(), "SkillSetId", "Name");
            try
            {
                _employeeService.AddSkillSetToEmployee(selectedEmployee);
                return View("Success");
            }
            catch
            {
                return View("Error");
            }

        }
        public ActionResult Edit(Employee selectedEmployee)
        {
            //ViewData["Projects"] = new MultiSelectList(_employeeService.GetAllProjects(), "ProjectId", "ProjectName");
            //ViewData["Skills"] = new MultiSelectList(_employeeService.GetAllSkillSets(), "SkillSetId", "Name");
            try
            {

                _employeeService.EditEmployee(selectedEmployee);
                return View("Success");
            }
            catch
            {
                return View("Error");
            }

        }