public async Task <ValidationResult> ValidateUpdateAsync(int id, ApiTransactionServerRequestModel model) { this.AmountRules(); this.ArtistIdRules(); this.DateCreatedRules(); this.StripeTransactionIdRules(); return(await this.ValidateAsync(model, id)); }
public JsonPatchDocument <ApiTransactionServerRequestModel> CreatePatch(ApiTransactionServerRequestModel model) { var patch = new JsonPatchDocument <ApiTransactionServerRequestModel>(); patch.Replace(x => x.Amount, model.Amount); patch.Replace(x => x.ArtistId, model.ArtistId); patch.Replace(x => x.DateCreated, model.DateCreated); patch.Replace(x => x.StripeTransactionId, model.StripeTransactionId); return(patch); }
public virtual ApiTransactionServerRequestModel MapServerResponseToRequest( ApiTransactionServerResponseModel response) { var request = new ApiTransactionServerRequestModel(); request.SetProperties( response.Amount, response.ArtistId, response.DateCreated, response.StripeTransactionId); return(request); }
public void MapModelToEntity() { var mapper = new DALTransactionMapper(); ApiTransactionServerRequestModel model = new ApiTransactionServerRequestModel(); model.SetProperties(1m, 1, DateTime.Parse("1/1/1987 12:00:00 AM"), "A"); Transaction response = mapper.MapModelToEntity(1, model); response.Amount.Should().Be(1m); response.ArtistId.Should().Be(1); response.DateCreated.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.StripeTransactionId.Should().Be("A"); }
public virtual Transaction MapModelToEntity( int id, ApiTransactionServerRequestModel model ) { Transaction item = new Transaction(); item.SetProperties( id, model.Amount, model.ArtistId, model.DateCreated, model.StripeTransactionId); return(item); }
public virtual async Task <CreateResponse <ApiTransactionServerResponseModel> > Create( ApiTransactionServerRequestModel model) { CreateResponse <ApiTransactionServerResponseModel> response = ValidationResponseFactory <ApiTransactionServerResponseModel> .CreateResponse(await this.TransactionModelValidator.ValidateCreateAsync(model)); if (response.Success) { Transaction record = this.DalTransactionMapper.MapModelToEntity(default(int), model); record = await this.TransactionRepository.Create(record); response.SetRecord(this.DalTransactionMapper.MapEntityToModel(record)); await this.mediator.Publish(new TransactionCreatedNotification(response.Record)); } return(response); }
public virtual async Task <UpdateResponse <ApiTransactionServerResponseModel> > Update( int id, ApiTransactionServerRequestModel model) { var validationResult = await this.TransactionModelValidator.ValidateUpdateAsync(id, model); if (validationResult.IsValid) { Transaction record = this.DalTransactionMapper.MapModelToEntity(id, model); await this.TransactionRepository.Update(record); record = await this.TransactionRepository.Get(id); ApiTransactionServerResponseModel apiModel = this.DalTransactionMapper.MapEntityToModel(record); await this.mediator.Publish(new TransactionUpdatedNotification(apiModel)); return(ValidationResponseFactory <ApiTransactionServerResponseModel> .UpdateResponse(apiModel)); } else { return(ValidationResponseFactory <ApiTransactionServerResponseModel> .UpdateResponse(validationResult)); } }