public async Task <IActionResult> UpdateResource(long id, UpdateResourceCommand command) { command.Id = id; await _resourceService.UpdateResource(command); return(Ok()); }
public void UpdateResource(UpdateResourceCommand cmd) { _previousName = this.Name; this.Name = cmd.Name; this.Amount = cmd.Amount; this.Observations = cmd.Observations; }
public async Task <CommandResult> Handle(UpdateResourceCommand request, CancellationToken cancellationToken) { var model = await _resourcePersistentRepository.GetByIdAsync(request.Id); model.UpdateResource(request); base.CommandResult.ValidationResult = await model.ValidateUpdateResourceAsync(_resourceReadOnlyRepository); if (base.HasErrors) { return(base.CommandResult); } _resourcePersistentRepository.Update(model); await _resourcePersistentRepository.SaveChangesAsync(); return(base.CommandResult); }
public async Task UpdateResource(UpdateResourceCommand command) { var resource = await _resourcesRepository.GetResource(command.Id); if (resource is null) { throw new Exception("Resource does not exist"); } resource.Specification = command.Specification; resource.SeriesNumber = command.SeriesNumber; resource.InstalationKey = command.InstalationKey; resource.DateOfPurchase = command.DateOfPurchase; resource.LocalizationId = command.LocalizationId; resource.UserId = command.UserId; resource.Type = command.Type; await _resourcesRepository.UpdateResource(resource); }
public async Task <DomainResource?> UpdateResource(UpdateResourceCommand r) { var resource = await _resources.FindById(r.id); if (resource == null) { throw new EntityNotFoundException(nameof(resource), $"(id == {r.id}"); } var rType = await _resources.FindResourceTypByType(r.ResourceTypeName); resource.ResourceType = rType; resource.MetaData = r.MetaData; resource.DisplayName = r.DisplayName; resource.Description = r.Description; var updated = await _resources.UpdateResource(resource); return(_mapper.Map <DomainResource>(updated)); }