public void AddEmployeeSkills(EmployeeSkillsDTO Record)
        {
            EmployeeSkill ReturnRecord = EmployeeSkillRequestFormatter.EmployeeSkillDTOToDb(Record);

            ReturnRecord.EmpSkillStatus = true;
            _unitOfWork.EmployeeSkillRepository.Create(ReturnRecord);
        }
        public EmployeeSkillsDTO GetOneEmployeeSkills(int Id)
        {
            EmployeeSkill     Record       = _unitOfWork.EmployeeSkillRepository.Get(x => x.Id == Id).FirstOrDefault();
            EmployeeSkillsDTO ReturnRecord = ResponseFormatters.EmployeeSkillResponseFormatter.EmplyeeSkillDbToDTO(Record);

            return(ReturnRecord);
        }
Example #3
0
        private static List <EmployeeSkill> GetEmployeeSkills(int accountID, string skillName, int skillTypeID,
                                                              SkillLevelEnum skillLevel)
        {
            List <EmployeeSkill> skills = new List <EmployeeSkill>();
            SqlCommand           cmd    = new SqlCommand();

            cmd.Parameters.Add(_AccountID, SqlDbType.Int).Value           = accountID;
            cmd.Parameters.Add(_SkillName, SqlDbType.NVarChar, 100).Value = skillName;
            cmd.Parameters.Add(_SkillID, SqlDbType.Int).Value             = skillTypeID;
            cmd.Parameters.Add(_SkillRank, SqlDbType.Int).Value           = skillLevel;
            using (
                SqlDataReader sdr =
                    SqlHelper.ExecuteReader("GetEmployeeSkillByAccountID", cmd))
            {
                while (sdr.Read())
                {
                    SkillType     type          = new SkillType(Convert.ToInt32(sdr[_DBSkillTypeId]), sdr[_DBSkillTypeName].ToString());
                    Skill         skill         = new Skill(Convert.ToInt32(sdr[_DBSkillID]), sdr[_DBSkillName].ToString(), type);
                    EmployeeSkill employeeSkill =
                        new EmployeeSkill(skill, (SkillLevelEnum)(sdr[_DBSkillRank]));
                    employeeSkill.EmpSkillID = Convert.ToInt32(sdr[_DBPKID]);
                    employeeSkill.Score      = Convert.ToDecimal(sdr[_DbScore]);
                    employeeSkill.Remark     = sdr[_DbRemark].ToString();
                    skills.Add(employeeSkill);
                }
            }
            return(skills);
        }
        public async Task <IHttpActionResult> Put([FromBody] EmployeeSkill employeeSkill)
        {
            try
            {
                EmployeeSkill skillFound = await _employeeSkillQuery.GetAsync(employeeSkill.EmployeeSkillId);

                if (skillFound == null)
                {
                    return(NotFound());
                }

                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                skillFound.Skill = employeeSkill.Skill;

                await _employeeSkillCommand.Update(skillFound);

                return(Ok(skillFound));
            }
            catch
            {
                return(Content(HttpStatusCode.Conflict, employeeSkill));
            }
        }
        ///<summary>Extracts data from the form,
        /// saves new inserted skills to skills table,
        /// and inserts employee skills to database</summary>
        ///<returns>Returns Employee after modifications
        /// to be added to or updated in the database</returns>
        private Employee ExtractData(EmployeeModelView employee)
        {
            string cleanedString = employee.EmployeeSkills ?? "";

            string[] inputSkills = cleanedString.Split(',');
            foreach (string inputSkill in inputSkills)
            {
                Skill skill = skillServices.GetByName(inputSkill);
                if (skill == null)
                {
                    skill = new Skill {
                        Name = inputSkill
                    };
                    skillServices.Add(skill);
                }
                EmployeeSkill employeeSkill = employeeSkillServices
                                              .GetById(new Tuple <int, int>(employee.Id, skill.Id));

                if (employeeSkill == null)
                {
                    employeeSkill            = new EmployeeSkill();
                    employeeSkill.EmployeeId = employee.Id;
                    employeeSkill.SkillId    = skill.Id;
                    employee.EmployeesSkills.Add(employeeSkill);
                    skill.EmployeesSkills.Add(employeeSkill);

                    employeeSkillServices.Add(employeeSkill);
                }
            }
            return(employee);
        }
        public async Task <ActionResult <EmployeeSkill> > PostEmployeeSkill(EmployeeSkill employeeSkill)
        {
            _context.EmployeeSkill.Add(employeeSkill);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetEmployeeSkill", new { id = employeeSkill.EmpSkillId }, employeeSkill));
        }
Example #7
0
        public ActionResult Edit(Employee employee)
        {
            string[] empSkills = employee.SelectedSkills;
            foreach (EmployeeSkill employeeSkill in db.EmployeeSkills)
            {
                if (employeeSkill.EmployeeID == employee.Id)
                {
                    db.EmployeeSkills.Remove(employeeSkill);
                }
            }

            if (employee.SelectedSkills != null)
            {
                foreach (string skill in empSkills)
                {
                    EmployeeSkill employeeSkill = new EmployeeSkill();
                    employeeSkill.SkillID    = Int16.Parse(skill);
                    employeeSkill.SkillName  = _skillService.GetSkillById(Int16.Parse(skill)).SkillName;
                    employeeSkill.EmployeeID = employee.Id;
                    db.EmployeeSkills.Add(employeeSkill);
                }
            }
            db.SaveChanges();

            if (ModelState.IsValid)
            {
                _employeeService.Update(employee);
                return(RedirectToAction("Index"));
            }
            return(View(employee));
        }
        public Task <bool> Handle(UpdateEmployeeCommand message, CancellationToken cancellationToken)
        {
            if (!EmployeeExists(message.Id, message.MessageType))
            {
                return(Task.FromResult(false));
            }

            var name = new Name(message.FirstName, message.LastName);
            var employeeSkillList = new List <EmployeeSkill>();

            foreach (var skill in message.Skills)
            {
                var id            = message.Id;
                var employeeSkill = new EmployeeSkill()
                {
                    EmployeeId = id, SkillId = skill.Id
                };
                employeeSkillList.Add(employeeSkill);
            }

            var employee = new Employee(message.Id, name, message.BirthDate, message.Email, message.Gender, employeeSkillList);

            if (!EmployeeValid(employee))
            {
                return(Task.FromResult(false));
            }

            _employeeRepository.Update(employee);

            Commit();

            return(Task.FromResult(true));
        }
        public async Task <int> CreateAsync(EmployeeSkill employeeSkill)
        {
            using var context = new AotDBContext();
            await context.EmployeeSkills.AddAsync(employeeSkill);

            return(await context.SaveChangesAsync());
        }
        public async Task <EmployeeSkill> AddAsync(EmployeeSkill employeeskill)
        {
            _dbContext.EmployeeSkill.Add(employeeskill);
            await _dbContext.SaveChangesAsync();

            return(employeeskill);
        }
        public void Init()
        {
            _ItsView.Title = "修改技能";
            _ItsView.Id    = string.Empty;
            new EmployeeSkillViewIniter(_ItsView).InitTheViewToDefault();

            int id;

            if (!int.TryParse(_Id, out id))
            {
                return;
            }
            EmployeeSkill theObject = FindEmployeeSkillById(id);

            if (theObject != null)
            {
                _ItsView.Id = theObject.HashCode.ToString();
                //Source Info.
                _ItsView.SkillTypeSource      = _ISkillTypeFacade.GetSkillTypeByCondition(-1, string.Empty);
                _ItsView.SkillLevelTypeSource = SkillLevelType.AllSkillLevelTypes;
                _ItsView.SkillSource          = _ISkillFacade.GetSkillByCondition(string.Empty, theObject.Skill.SkillType.ParameterID);
                //Basic Info.
                _ItsView.SkillType  = theObject.Skill.SkillType.ParameterID.ToString();
                _ItsView.Skill      = theObject.Skill.SkillID.ToString();
                _ItsView.SkillLevel = ((Int32)theObject.SkillLevel).ToString();
                _ItsView.Score      = theObject.Score.ToString();
                _ItsView.Remark     = theObject.Remark;
            }
        }
        public async Task <IActionResult> PutEmployeeSkill(int id, EmployeeSkill employeeSkill)
        {
            if (id != employeeSkill.EmployeeId)
            {
                return(BadRequest());
            }

            _context.Entry(employeeSkill).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EmployeeSkillExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #13
0
        static void getEmployeeSkills()
        {
            Console.Write("EMPLOYEESKILLS: ");
            DataTable rawData = Utility.OpenExcel(sourceData, "EmployeeSkill");
            int       N       = 0;

            foreach (DataRow row in rawData.Rows)
            {
                string toolName = Utility.getString(row, 2);
                Tool   tool     = context.Tools.Where(x => x.Name == toolName).FirstOrDefault();

                string employeeName = Utility.getString(row, 3);
                Person employee     = context.People.Where(x => x.FirstName == employeeName).FirstOrDefault();

                int exp = Utility.getInteger(row, 1);

                EmployeeSkill empSkill = new EmployeeSkill()
                {
                    Level      = (Level)Utility.getInteger(row, 0),
                    Experience = Utility.getInteger(row, 1),
                    Tool       = tool,
                    Employee   = employee
                };

                if (exp > 0)
                {
                    empSkill.Experience = exp;
                }

                N++;
                context.EmployeeSkills.Add(empSkill);
            }
            context.SaveChanges();
            Console.WriteLine(N);
        }
Example #14
0
        public ActionResult DeleteConfirmed(int id)
        {
            EmployeeSkill employeeSkill = db.EmployeesSkills.Find(id);

            db.EmployeesSkills.Remove(employeeSkill);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public void UpdateEmployeeSkill(EmployeeSkillsDTO Record)
        {
            EmployeeSkill ReturnRecord = EmployeeSkillRequestFormatter.EmployeeSkillDTOToDb(Record);

            ReturnRecord.EmpCode        = Record.EmpId;
            ReturnRecord.EmpSkillStatus = true;
            _unitOfWork.EmployeeSkillRepository.Update(ReturnRecord);
        }
Example #16
0
        public void Update(EmployeeSkill entity)
        {
            DBEmployeeSkill dbEmplSk =
                Mapper.Map <EmployeeSkill, DBEmployeeSkill>(entity);

            //new DBEmployeeSkill { Email = entity.Email, FullName = entity.FullName, Id = entity.Id, Position = entity.Position, StartDate = entity.StartDate };
            DB.EmployeeSkills.Update(dbEmplSk);
            DB.SaveChanges();
        }
Example #17
0
        public async Task <int> DeleteEmployeeSkill(int employeeSkillId)
        {
            var employeeSkill = new EmployeeSkill
            {
                EmployeeSkillId = employeeSkillId
            };

            _db.EmployeeSkill.Remove(employeeSkill);
            return(_db.SaveChanges());
        }
Example #18
0
 public ActionResult Edit([Bind(Include = "EmployeeSkillID,EmployeeSkillName")] EmployeeSkill employeeSkill)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employeeSkill).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(employeeSkill));
 }
Example #19
0
        public ActionResult Create([Bind(Include = "EmployeeSkillID,EmployeeSkillName")] EmployeeSkill employeeSkill)
        {
            if (ModelState.IsValid)
            {
                db.EmployeeSkills.Add(employeeSkill);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(employeeSkill));
        }
        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());
        }
        public EmployeeSkill GetEmployeeSkill(int id)
        {
            EmployeeSkill employeeSkill = db.EmployeeSkills.FirstOrDefault(p => p.Id == id);

            if (employeeSkill == null)
            {
                return(null);
            }

            return(employeeSkill);
        }
Example #22
0
        public async Task <int> AddEmployeeSkill(int employeeId, int skillId)
        {
            var employeeSkill = new EmployeeSkill
            {
                EmployeeId = employeeId,
                SkillId    = skillId
            };

            _db.EmployeeSkill.Add(employeeSkill);
            return(_db.SaveChanges());
        }
 public ActionResult EditEmployeeSkill([Bind(Include = "Id,EmployeeId,SkillId,Details")] EmployeeSkill employeeskill)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employeeskill).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("ViewEmployeeSkill"));
     }
     ViewBag.EmployeeId = new SelectList(db.Employees, "Id", "EmployeeRegNo", employeeskill.EmployeeId);
     ViewBag.SkillId    = new SelectList(db.Skills, "Id", "SkillName", employeeskill.SkillId);
     return(View(employeeskill));
 }
Example #24
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            //Delete the Skill
            EmployeeSkill employeeSkill = await db.EmployeeSkills.FirstOrDefaultAsync(x => x.Id == id);

            db.EmployeeSkills.Remove(employeeSkill);

            //Call the EF to save chages
            await db.SaveChangesAsync();

            return(RedirectToAction("Edit", "Employee", new { Id = employeeSkill.EmployeeId }));
        }
        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 static EmployeeSkill EmployeeSkillDTOToDb(EmployeeSkillsDTO ModelData)
        {
            EmployeeSkill Record = new EmployeeSkill
            {
                Id             = ModelData.Id,
                EmpCode        = ModelData.EmpCode,
                EmpSkillId     = ModelData.EmpSkillId,
                EmpSkillPoint  = ModelData.EmpSkillPoint,
                EmpSkillStatus = ModelData.EmpSkillStatus
            };

            return(Record);
        }
Example #27
0
        public async Task <string> UpdateEmployeeSkill(int id, EmployeeSkill employeeSkill)
        {
            try
            {
                var res = await _repository.UpdateEmployeeSkills(id, employeeSkill);

                return(res);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #28
0
        public async Task <EmployeeSkill> CreateNewEmployeeSkill(EmployeeSkill employeeSkill)
        {
            try
            {
                var res = await _repository.CreateNewEmployeeSkills(employeeSkill);

                return(res);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #29
0
        public ActionResult Edit([Bind(Include = "EmployeeSkillId,Level,SkillId,EmployeeId")] EmployeeSkill employeeSkill)
        {
            if (ModelState.IsValid)
            {
                EmployeeSkill e = db.EmployeesSkills.Find(employeeSkill.EmployeeSkillId);
                e.Level = employeeSkill.Level;

                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(employeeSkill));
        }
        public async Task <ActionResult <EmployeeSkill> > DeleteEmployeeSkill(int eid, int sid)
        {
            EmployeeSkill employeeSkill = _context.EmployeeSkill.Where(c => c.EmployeeId == eid && c.SkillId == sid).FirstOrDefault();

            if (employeeSkill == null)
            {
                return(NotFound());
            }

            _context.EmployeeSkill.Remove(employeeSkill);
            await _context.SaveChangesAsync();

            return(Ok());
        }