Ejemplo n.º 1
0
        public UpdateSkillResponse UpdateSkill(UpdateSkillRequest request)
        {
            _skillRepository.UpdateSkill(new UpdateSkillDto
            {
                Id    = request.Id,
                Name  = request.Name,
                Score = request.Score
            });

            return(new UpdateSkillResponse());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Update([FromRoute] Guid id, [FromBody] UpdateSkillRequest request)
        {
            var userOwnsSkill = await _skillService.UserOwnsSkillAsync(id, HttpContext.GetUserId());

            if (!userOwnsSkill)
            {
                return(NotFound());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var skill = await _skillService.GetSkillByIdAsync(id);

            if (skill == null)
            {
                return(NotFound());
            }
            if (request.ContactID != null)
            {
                skill.ContactID = (Guid)request.ContactID;
                skill.Contact   = await _contactService.GetContactByIdAsync(skill.ContactID);

                if (skill.Contact == null)
                {
                    ModelState.AddModelError("ContactID", $"Contact {skill.ContactID} not found.");
                    return(BadRequest(ModelState));
                }
            }
            if (request.Name != null)
            {
                skill.Name = request.Name;
            }
            if (request.Level != null)
            {
                skill.Level = request.Level;
            }

            var updated = await _skillService.UpdateSkill(skill);

            if (updated)
            {
                return(Ok(new Response <Skill>(skill)));
            }
            return(NotFound());
        }
 public async Task UpdateSkill([FromRoute] Guid customerId, [FromRoute] Guid id, [FromBody] UpdateSkillRequest request)
 => await _mediator.Send(
     new UpdateSkillCommand(customerId, id, request.Name, request.Proficiency, request.Experience)
     );