public ActionResult Create(Skill skill) { if (ModelState.IsValid) { _skillRepository.Add(skill); _skillRepository.Commit(); return(RedirectToAction("Index")); } return(View(skill)); }
public IActionResult Create([FromBody] SkillDto skillVM) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var skill = new Skill { Name = skillVM.Name, IsReg = skillVM.IsReg, KeyWords = skillVM.KeyWords }; _skillRepository.Add(skill); _skillRepository.Commit(); _workerService.RegisterTask("skill", skill.Id); skillVM = Mapper.Map <Skill, SkillDto>(skill); CreatedAtRouteResult result = CreatedAtRoute("GetSkill", new { controller = "Skills", id = skillVM.Id }, skillVM); return(result); }