Exemple #1
0
        public async Task <ServiceResponse <GetSkillDto> > UpdateSkill(int id, UpdateSkillDto updateSkillDto)
        {
            ServiceResponse <GetSkillDto> response = new ServiceResponse <GetSkillDto> ();

            try {
                var skill = await _context.Skills.FirstOrDefaultAsync(s => s.Id == id);

                if (skill == null)
                {
                    response.Success = false;
                    response.Message = $"Skill with id {id} not found";
                    return(response);
                }
                var updateSkill = _mapper.Map <Skill> (updateSkillDto);
                _context.Entry(updateSkill).State = EntityState.Modified;
                await _context.SaveChangesAsync();

                response.Data = _mapper.Map <GetSkillDto> (updateSkill);
            } catch (System.Exception ex) {
                response.Success = false;
                response.Message = ex.Message;
            }

            return(response);
        }
Exemple #2
0
        public async Task <SkillDto> UpdateSkillAsync(UpdateSkillDto input)
        {
            var skill = await _skillRepo.GetAsync(input.Id);

            ObjectMapper.Map(input, skill);
            var savedSkill = await _skillRepo.UpdateAsync(skill);

            return(ObjectMapper.Map <SkillDto>(savedSkill));
        }
        public int UpdateSkill(UpdateSkillDto update)
        {
            _uow.Skill.Update(new Skill
            {
                Id    = update.Id,
                Name  = update.Name,
                Score = update.Score
            });

            return(_uow.SaveChanges());
        }
        public async Task <ApiResponse> Update(Guid id, UpdateSkillDto request)
        {
            var command = new UpdateSkillCommand
            {
                Id     = id,
                Name   = request.Name,
                Damage = request.Damage
            };
            await _operationMediator.HandleAsync(command);

            return(ApiResponse.Ok());
        }
        public async Task <IActionResult> UpdateSkill(int id, UpdateSkillDto updateSkillDto)
        {
            if (id != updateSkillDto.Id)
            {
                return(BadRequest());
            }
            ServiceResponse <GetSkillDto> response = await _skillService.UpdateSkill(id, updateSkillDto);

            if (!response.Success)
            {
                return(BadRequest(response));
            }
            if (response.Data == null)
            {
                return(NotFound(response));
            }
            return(Ok(response));
        }
Exemple #6
0
 public async Task <SkillDto> Update(UpdateSkillDto input)
 {
     return(await _skillAppService.UpdateSkillAsync(input));
 }
        public async Task <ServiceResponse <GetSkillDto> > UpdateSkill(UpdateSkillDto skill)
        {
            ServiceResponse <GetSkillDto> response = new ServiceResponse <GetSkillDto>();

            return(response);
        }