public JsonPatchDocument <ApiSpeciesServerRequestModel> CreatePatch(ApiSpeciesServerRequestModel model) { var patch = new JsonPatchDocument <ApiSpeciesServerRequestModel>(); patch.Replace(x => x.Name, model.Name); return(patch); }
public virtual ApiSpeciesServerRequestModel MapServerResponseToRequest( ApiSpeciesServerResponseModel response) { var request = new ApiSpeciesServerRequestModel(); request.SetProperties( response.Name); return(request); }
public void MapModelToEntity() { var mapper = new DALSpeciesMapper(); ApiSpeciesServerRequestModel model = new ApiSpeciesServerRequestModel(); model.SetProperties("A"); Species response = mapper.MapModelToEntity(1, model); response.Name.Should().Be("A"); }
public virtual ApiSpeciesServerResponseModel MapServerRequestToResponse( int id, ApiSpeciesServerRequestModel request) { var response = new ApiSpeciesServerResponseModel(); response.SetProperties(id, request.Name); return(response); }
public virtual Species MapModelToEntity( int id, ApiSpeciesServerRequestModel model ) { Species item = new Species(); item.SetProperties( id, model.Name); return(item); }
public virtual async Task <CreateResponse <ApiSpeciesServerResponseModel> > Create( ApiSpeciesServerRequestModel model) { CreateResponse <ApiSpeciesServerResponseModel> response = ValidationResponseFactory <ApiSpeciesServerResponseModel> .CreateResponse(await this.SpeciesModelValidator.ValidateCreateAsync(model)); if (response.Success) { Species record = this.DalSpeciesMapper.MapModelToEntity(default(int), model); record = await this.SpeciesRepository.Create(record); response.SetRecord(this.DalSpeciesMapper.MapEntityToModel(record)); await this.mediator.Publish(new SpeciesCreatedNotification(response.Record)); } return(response); }
public virtual async Task <UpdateResponse <ApiSpeciesServerResponseModel> > Update( int id, ApiSpeciesServerRequestModel model) { var validationResult = await this.SpeciesModelValidator.ValidateUpdateAsync(id, model); if (validationResult.IsValid) { Species record = this.DalSpeciesMapper.MapModelToEntity(id, model); await this.SpeciesRepository.Update(record); record = await this.SpeciesRepository.Get(id); ApiSpeciesServerResponseModel apiModel = this.DalSpeciesMapper.MapEntityToModel(record); await this.mediator.Publish(new SpeciesUpdatedNotification(apiModel)); return(ValidationResponseFactory <ApiSpeciesServerResponseModel> .UpdateResponse(apiModel)); } else { return(ValidationResponseFactory <ApiSpeciesServerResponseModel> .UpdateResponse(validationResult)); } }