public JsonPatchDocument <ApiAirTransportServerRequestModel> CreatePatch(ApiAirTransportServerRequestModel model) { var patch = new JsonPatchDocument <ApiAirTransportServerRequestModel>(); patch.Replace(x => x.AirlineId, model.AirlineId); patch.Replace(x => x.FlightNumber, model.FlightNumber); patch.Replace(x => x.HandlerId, model.HandlerId); patch.Replace(x => x.LandDate, model.LandDate); patch.Replace(x => x.PipelineStepId, model.PipelineStepId); patch.Replace(x => x.TakeoffDate, model.TakeoffDate); return(patch); }
public virtual ApiAirTransportServerRequestModel MapServerResponseToRequest( ApiAirTransportServerResponseModel response) { var request = new ApiAirTransportServerRequestModel(); request.SetProperties( response.AirlineId, response.FlightNumber, response.HandlerId, response.LandDate, response.PipelineStepId, response.TakeoffDate); return(request); }
public void MapModelToEntity() { var mapper = new DALAirTransportMapper(); ApiAirTransportServerRequestModel model = new ApiAirTransportServerRequestModel(); model.SetProperties(1, "A", 1, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, DateTime.Parse("1/1/1987 12:00:00 AM")); AirTransport response = mapper.MapModelToEntity(1, model); response.AirlineId.Should().Be(1); response.FlightNumber.Should().Be("A"); response.HandlerId.Should().Be(1); response.LandDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.PipelineStepId.Should().Be(1); response.TakeoffDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); }
public virtual async Task <CreateResponse <ApiAirTransportServerResponseModel> > Create( ApiAirTransportServerRequestModel model) { CreateResponse <ApiAirTransportServerResponseModel> response = ValidationResponseFactory <ApiAirTransportServerResponseModel> .CreateResponse(await this.AirTransportModelValidator.ValidateCreateAsync(model)); if (response.Success) { AirTransport record = this.DalAirTransportMapper.MapModelToEntity(default(int), model); record = await this.AirTransportRepository.Create(record); response.SetRecord(this.DalAirTransportMapper.MapEntityToModel(record)); await this.mediator.Publish(new AirTransportCreatedNotification(response.Record)); } return(response); }
public virtual AirTransport MapModelToEntity( int id, ApiAirTransportServerRequestModel model ) { AirTransport item = new AirTransport(); item.SetProperties( id, model.AirlineId, model.FlightNumber, model.HandlerId, model.LandDate, model.PipelineStepId, model.TakeoffDate); return(item); }
public virtual async Task <UpdateResponse <ApiAirTransportServerResponseModel> > Update( int id, ApiAirTransportServerRequestModel model) { var validationResult = await this.AirTransportModelValidator.ValidateUpdateAsync(id, model); if (validationResult.IsValid) { AirTransport record = this.DalAirTransportMapper.MapModelToEntity(id, model); await this.AirTransportRepository.Update(record); record = await this.AirTransportRepository.Get(id); ApiAirTransportServerResponseModel apiModel = this.DalAirTransportMapper.MapEntityToModel(record); await this.mediator.Publish(new AirTransportUpdatedNotification(apiModel)); return(ValidationResponseFactory <ApiAirTransportServerResponseModel> .UpdateResponse(apiModel)); } else { return(ValidationResponseFactory <ApiAirTransportServerResponseModel> .UpdateResponse(validationResult)); } }