Beispiel #1
0
        public async Task <IActionResult> PostSkills([FromBody] InputSkillModel skill)
        {
            //In this api we are using this type of model that complicates the code, because swagger generates the
            // scheme in the documentation more precise with this one
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }


            try
            {
                _context.Skills.Add(new SkillModel()
                {
                    SkillName = skill.SkillName
                });
                await _context.SaveChangesAsync();
            }
            catch (Exception e)
            {
                return(BadRequest(e.InnerException.Message));
            }

            return(Ok("Success"));
        }
Beispiel #2
0
        public IActionResult EditSkill(InputSkillModel inputSkillModel)
        {
            if (inputSkillModel == null)
            {
                return(new StatusCodeResult((int)HttpStatusCode.BadRequest));
            }

            var skill = context.Skills.FirstOrDefault(x => x.Id == inputSkillModel.Id);

            //var employeeskill = context.EmployeeSkills.FirstOrDefault(x => x.Id == inputSkillModel.Id);

            if (skill == null /*|| employeeskill == null*/)
            {
                return(new StatusCodeResult((int)HttpStatusCode.NotFound));
            }

            skill.SkillName         = inputSkillModel.Name;
            skill.ExperienceInYears = inputSkillModel.Experience;
            skill.Profficiency      = inputSkillModel.Profficiency;
            //employeeskill.ExperienceInYears = inputSkillModel.Experience;
            //employeeskill.Profficiency = inputSkillModel.Profficiency;

            context.SaveChanges();

            return(StatusCode((int)HttpStatusCode.OK));
        }
Beispiel #3
0
 public IActionResult AddSkill(InputSkillModel inputSkillModel)
 {
     context.Skills.Add(new Skill()
     {
         SkillName = inputSkillModel.Name,
     });
     context.SaveChanges();
     return(StatusCode((int)HttpStatusCode.OK));
 }
Beispiel #4
0
        public IActionResult AddSkill(InputSkillModel inputSkillModel)
        {
            context.Skills.Add(new Skill()
            {
                SkillName         = inputSkillModel.Name,
                ExperienceInYears = inputSkillModel.Experience,
                Profficiency      = inputSkillModel.Profficiency
            });

            //context.EmployeeSkills.Add(new EmployeeSkill()
            //{
            //    ExperienceInYears = inputSkillModel.Experience,
            //    Profficiency = inputSkillModel.Profficiency
            //});

            context.SaveChanges();
            return(StatusCode((int)HttpStatusCode.OK));
        }
Beispiel #5
0
        public IActionResult EditSkill(InputSkillModel inputSkillModel)
        {
            if (inputSkillModel == null)
            {
                return(new StatusCodeResult((int)HttpStatusCode.BadRequest));
            }
            var skill = context.Skills.FirstOrDefault(x => x.Id == inputSkillModel.Id);

            if (skill == null)
            {
                return(new StatusCodeResult((int)HttpStatusCode.NotFound));
            }

            skill.SkillName = inputSkillModel.Name;
            context.SaveChanges();

            return(StatusCode((int)HttpStatusCode.OK));
        }