public async Task <ActionResult <Skill> > InsertSkill(SkillInsertUpdateResource resource) { var newSkill = _mapper.Map <SkillInsertUpdateResource, Skill>(resource); newSkill.Id = Guid.NewGuid(); newSkill.CreationDate = DateTime.Now; newSkill.UpdateDate = DateTime.Now; await _context.AddAsync(newSkill); await _context.SaveChangesAsync(); return(Ok(newSkill)); }
public async Task <ActionResult <Skill> > UpdateSkill(Guid id, SkillInsertUpdateResource resource) { var skill = await _context.Skills.FindAsync(id); if (skill == null) { return(NotFound()); } skill.UpdateDate = DateTime.Now; _mapper.Map(resource, skill); await _context.SaveChangesAsync(); return(Ok(skill));//(skill); }