private void MapViewModelsToCommands() { this.CreateMap <AddCarViewModel, AddCarCommand>() .ConstructUsing(source => new AddCarCommand(CarId.NewComb(), source.Name, source.BatteryCapacity)); this.CreateMap <EditCarViewModel, EditCarCommand>() .ConstructUsing(source => new EditCarCommand(CarId.With(Guid.Parse(source.Id)), source.Name, source.BatteryCapacity)); this.CreateMap <DeleteCarViewModel, DeleteCarCommand>() .ConstructUsing(source => new DeleteCarCommand(CarId.With(Guid.Parse(source.Id)))); }
public async Task <IActionResult> PatchCar([FromRoute] Guid id, [FromBody] CarInputModel model) { var aggregateId = CarId.With(id); var command = new ChangeCarNameCommand(aggregateId, model.Name); var executionResult = await _aggregateManager.Ask <ExecutionResult>(command); if (executionResult.IsSuccess) { return(Accepted(new { Id = aggregateId.GetGuid() })); } return(BadRequest(executionResult.ToString())); }
public CarById(string id) { this.Id = CarId.With(Guid.Parse(id)).Value; }
public UserIsCarOwner(string id) { this.Id = CarId.With(Guid.Parse(id)).Value; }
public CarWithNameDoesNotExist(string name, string exceptId = null) { this.Name = name; this.ExceptId = string.IsNullOrWhiteSpace(exceptId) ? null : CarId.With(Guid.Parse(exceptId)).Value; }
public CarsByIds(List <string> ids) { this.Ids = ids?.Select(id => CarId.With(Guid.Parse(id)).Value).Distinct().ToList() ?? new List <string>(); }