public async Task <ActionResult> Post([FromForm] SkillCreationDTO skillCreationDTO) { var skill = mapper.Map <Skill>(skillCreationDTO); if (skillCreationDTO.Icon != null) { skill.Icon = await fileStorageService.SaveFile(containerName, skillCreationDTO.Icon); } skill.Order = await context.Skills.CountAsync(); context.Add(skill); await context.SaveChangesAsync(); return(NoContent()); }
public async Task <ActionResult> Put(int id, [FromForm] SkillCreationDTO skillCreationDTO) { var skill = await context.Skills.FirstOrDefaultAsync(x => x.Id == id); if (skill == null) { return(NotFound()); } skill = mapper.Map(skillCreationDTO, skill); if (skillCreationDTO.Icon != null) { skill.Icon = await fileStorageService.EditFile(containerName, skillCreationDTO.Icon, skill.Icon); } await context.SaveChangesAsync(); return(NoContent()); }