コード例 #1
0
        /// <summary>
        /// Updates user skill level in the db if user skill exists, otherwise inserts user skill.
        /// </summary>
        /// <exception cref="ArgumentNullException"></exception>
        public async Task SaveSkillLevel(EmployeeSkillDTO employeeSkillDto, string userId)
        {
            if (employeeSkillDto == null)
            {
                throw new ArgumentNullException(nameof(employeeSkillDto));
            }
            if (String.IsNullOrEmpty(userId))
            {
                throw new ArgumentNullException(nameof(userId));
            }

            UserProfileSkillsEntity skill = await employeeUnitOfWork.UserProfileSkills.GetByID(employeeSkillDto.SkillId, userId);

            if (skill != null)
            {
                skill.SkillLevel = (int)employeeSkillDto.Level;
            }
            else
            {
                skill = new UserProfileSkillsEntity {
                    DomainId = employeeSkillDto.DomainId, SkillId = employeeSkillDto.SkillId, SkillLevel = (int)employeeSkillDto.Level, UserProfileID = userId
                };
                employeeUnitOfWork.UserProfileSkills.Insert(skill);
            }
            await employeeUnitOfWork.SaveAsync();
        }
コード例 #2
0
        public async Task <IActionResult> PutEmployeeSkill(int id, EmployeeSkillDTO employeeSkillDto)
        {
            //if (id != employeeSkill.pkAuto)
            //{
            //    return BadRequest();
            //}

            EmployeeSkill empSkill = await _context.EmployeeSkill.Where(d => d.empId.empId == employeeSkillDto.empId && d.SkillId.skillId == employeeSkillDto.SkillId)
                                     .Select(d => d).FirstOrDefaultAsync();

            //var employeeSkill = await _context.EmployeeSkill.FindAsync(id);
            EmployeeInfo emp = await _context.EmployeeInfo.FindAsync(employeeSkillDto.empId);

            SkillMaster skill = await _context.SkillMaster.FindAsync(employeeSkillDto.SkillId);

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

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

            empSkill.pkAuto          = empSkill.pkAuto;
            empSkill.primary         = employeeSkillDto.primary;
            empSkill.empId           = emp;
            empSkill.empName         = employeeSkillDto.empName;
            empSkill.rating          = employeeSkillDto.rating;
            empSkill.hccOrganization = employeeSkillDto.hccOrganization;
            empSkill.grade           = employeeSkillDto.grade;
            empSkill.lastUpdatedDate = employeeSkillDto.lastUpdatedDate;
            empSkill.skillStartDate  = employeeSkillDto.skillStartDate;
            empSkill.skillEndDate    = employeeSkillDto.skillEndDate;
            empSkill.group           = employeeSkillDto.group;
            empSkill.skillType       = employeeSkillDto.skillType;
            empSkill.approvedBy      = employeeSkillDto.approvedBy;
            empSkill.approvedDate    = employeeSkillDto.approvedDate;
            empSkill.SkillId         = skill;
            empSkill.approvalStatus  = employeeSkillDto.approvalStatus;

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

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

            return(NoContent());
        }
コード例 #3
0
 public IHttpActionResult Post(EmployeeSkillDTO emplSkill)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     try
     {
         EmployeeSkill record = Mapper.Map <EmployeeSkillDTO, EmployeeSkill>(emplSkill);
         emplSkillService.Add(record);
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
     return(CreatedAtRoute("DefaultApi", new { id = emplSkill.Id }, emplSkill));
 }
コード例 #4
0
        public IHttpActionResult Delete(int id, EmployeeSkillDTO emplSkill)
        {
            if (id != emplSkill.Id)
            {
                return(BadRequest());
            }

            try
            {
                emplSkillService.Delete(Mapper.Map <EmployeeSkillDTO, EmployeeSkill>(emplSkill));
            }
            catch (Exception ex)
            {
                return(NotFound());
            }

            return(Ok());
        }
コード例 #5
0
        public async Task <ActionResult> UpdateEmployeeSkill(EmployeeSkillDTO model)
        {
            if (employeeService is IEmployeeService serv)
            {
                try
                {
                    await serv.SaveSkillLevel(model, User.Identity.GetUserId());

                    return(new HttpStatusCodeResult(HttpStatusCode.OK));
                }
                catch (Exception)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
                }
            }
            else
            {
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
            }
        }
コード例 #6
0
        public IHttpActionResult Put(int id, EmployeeSkillDTO emplSkill)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != emplSkill.Id)
            {
                return(BadRequest());
            }

            try
            {
                emplSkillService.Update(Mapper.Map <EmployeeSkillDTO, EmployeeSkill>(emplSkill));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }