コード例 #1
0
ファイル: Car.cs プロジェクト: i-dentify/echarge
 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))));
 }
コード例 #2
0
ファイル: CarsController.cs プロジェクト: lulzzz/Entropy
        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()));
        }
コード例 #3
0
 public CarById(string id)
 {
     this.Id = CarId.With(Guid.Parse(id)).Value;
 }
コード例 #4
0
 public UserIsCarOwner(string id)
 {
     this.Id = CarId.With(Guid.Parse(id)).Value;
 }
コード例 #5
0
 public CarWithNameDoesNotExist(string name, string exceptId = null)
 {
     this.Name     = name;
     this.ExceptId = string.IsNullOrWhiteSpace(exceptId) ? null : CarId.With(Guid.Parse(exceptId)).Value;
 }
コード例 #6
0
 public CarsByIds(List <string> ids)
 {
     this.Ids = ids?.Select(id => CarId.With(Guid.Parse(id)).Value).Distinct().ToList() ?? new List <string>();
 }