public async Task <ActionResult <EmployeeSkill> > PostEmployeeSkill(EmpSkillPostDTO empSkillPostDTO)
        {
            EmployeeInfo emp = await _context.EmployeeInfo.FindAsync(Convert.ToInt32(empSkillPostDTO.empId));

            SkillMaster skill = await _context.SkillMaster.FindAsync(Convert.ToInt32(empSkillPostDTO.SkillId));


            if (emp == null || skill == null)
            {
                return(NotFound());
            }

            var check = await _context.EmployeeSkill.Where(e => e.empId.empId == Convert.ToInt32(empSkillPostDTO.empId) && e.SkillId.skillId == Convert.ToInt32(empSkillPostDTO.SkillId)).Select(e => e).FirstOrDefaultAsync();

            if (check != null)
            {
                return(BadRequest("Skill already exists !!"));
            }

            EmployeeSkill empSkill = new EmployeeSkill();

            empSkill.primary = Convert.ToInt32(empSkillPostDTO.primary);
            empSkill.empId   = emp;

            empSkill.empName = emp.empName;

            empSkill.rating = Convert.ToInt32(empSkillPostDTO.rating);

            empSkill.hccOrganization = emp.hccOrganization;

            empSkill.grade = emp.grade;

            empSkill.lastUpdatedDate = DateTime.Now;
            empSkill.skillStartDate  = Convert.ToDateTime(empSkillPostDTO.skillStartDate);
            empSkill.skillEndDate    = Convert.ToDateTime(empSkillPostDTO.skillEndDate);
            empSkill.group           = empSkillPostDTO.group;
            empSkill.skillType       = empSkillPostDTO.skillType;

            empSkill.approvedBy = null;

            empSkill.approvedDate = null;

            empSkill.SkillId = skill;

            //empSkill.approvalStatus = Convert.ToInt32(empSkillPostDTO.approvalStatus);
            empSkill.approvalStatus = 0;

            _context.EmployeeSkill.Add(empSkill);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetEmployeeSkill", new { id = empSkill.pkAuto }, empSkillPostDTO));
        }
        public async Task <IActionResult> PutEmployeeSkill(EmpSkillPostDTO empSkillPostDTO)
        {
            EmployeeSkill empSkill = await _context.EmployeeSkill.Where(d => d.empId.empId == Convert.ToInt32(empSkillPostDTO.empId) && d.SkillId.skillId == Convert.ToInt32(empSkillPostDTO.SkillId))
                                     .Select(d => d).FirstOrDefaultAsync();



            EmployeeInfo emp = await _context.EmployeeInfo.FindAsync(Convert.ToInt32(empSkillPostDTO.empId));

            SkillMaster skill = await _context.SkillMaster.FindAsync(Convert.ToInt32(empSkillPostDTO.SkillId));



            if (empSkill == null || emp == null || skill == null)
            {
                _log4net.Fatal(DateTime.Today.Date + "; Input = " + empSkillPostDTO.empId + "; Controller: EmployeeSkillsController" + "; Exception: Given details of Emp_Skill does not exist");
                return(NotFound());
            }



            empSkill.empId   = emp;
            empSkill.SkillId = skill;



            empSkill.pkAuto  = empSkill.pkAuto;
            empSkill.primary = Convert.ToInt32(empSkillPostDTO.primary);
            empSkill.empId   = emp;
            empSkill.rating  = Convert.ToInt32(empSkillPostDTO.rating);



            empSkill.lastUpdatedDate = DateTime.Now;

            empSkill.skillStartDate = empSkillPostDTO.skillStartDate;
            empSkill.skillEndDate   = empSkillPostDTO.skillEndDate;
            empSkill.group          = empSkillPostDTO.group;
            empSkill.skillType      = empSkillPostDTO.skillType;
            empSkill.SkillId        = skill;
            empSkill.approvalStatus = 0;



            //   _context.Entry(empSkill).State = EntityState.Modified;

            _context.MarkAsModified(empSkill);



            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                return(NotFound());
            }



            return(NoContent());
        }