コード例 #1
0
        public async Task <ActionResult> Put(Guid id, [FromBody] UpdateComponentCommand command)
        {
            command.Id = id;
            var result = await _componentService.Update(command);

            return(Ok(result));
        }
コード例 #2
0
        public async Task <Component> Update(UpdateComponentCommand command)
        {
            var component = new Component
            {
                Id     = Guid.Parse(command.Id),
                Name   = command.Name,
                Amount = command.Amount
            };

            await _componentRepository.Update(component);

            return(component);
        }
コード例 #3
0
        public async Task <Component> Update(UpdateComponentCommand command)
        {
            var component = new Component
            {
                Id          = command.Id,
                Name        = command.Name,
                Brand       = command.Brand,
                Description = command.Description,
                ImagePath   = command.ImagePath,
                Price       = command.Price,
                Amount      = command.Amount,
                Type        = command.Type
            };
            //am pus
            // await _componentRepository.RemoveComponent(command.Id);
            //pana aici
            await _componentRepository.Update(component);

            return(component);
        }
コード例 #4
0
        public async Task <ActionResult <ComponentResource> > UpdateComponentAsync([FromRoute] int id, UpdateComponentCommand componentCommand)
        {
            componentCommand.Id = id;

            var componentResource = await _mediator.Send(componentCommand);

            if (componentResource == null)
            {
                return(NotFound());
            }

            return(componentResource);
        }