public JsonPatchDocument <ApiVoteTypeServerRequestModel> CreatePatch(ApiVoteTypeServerRequestModel model) { var patch = new JsonPatchDocument <ApiVoteTypeServerRequestModel>(); patch.Replace(x => x.Name, model.Name); return(patch); }
public virtual ApiVoteTypeServerRequestModel MapServerResponseToRequest( ApiVoteTypeServerResponseModel response) { var request = new ApiVoteTypeServerRequestModel(); request.SetProperties( response.Name); return(request); }
public void MapModelToEntity() { var mapper = new DALVoteTypeMapper(); ApiVoteTypeServerRequestModel model = new ApiVoteTypeServerRequestModel(); model.SetProperties("A"); VoteType response = mapper.MapModelToEntity(1, model); response.Name.Should().Be("A"); }
public virtual ApiVoteTypeServerResponseModel MapServerRequestToResponse( int id, ApiVoteTypeServerRequestModel request) { var response = new ApiVoteTypeServerResponseModel(); response.SetProperties(id, request.Name); return(response); }
public virtual VoteType MapModelToEntity( int id, ApiVoteTypeServerRequestModel model ) { VoteType item = new VoteType(); item.SetProperties( id, model.Name); return(item); }
public virtual async Task <CreateResponse <ApiVoteTypeServerResponseModel> > Create( ApiVoteTypeServerRequestModel model) { CreateResponse <ApiVoteTypeServerResponseModel> response = ValidationResponseFactory <ApiVoteTypeServerResponseModel> .CreateResponse(await this.VoteTypeModelValidator.ValidateCreateAsync(model)); if (response.Success) { VoteType record = this.DalVoteTypeMapper.MapModelToEntity(default(int), model); record = await this.VoteTypeRepository.Create(record); response.SetRecord(this.DalVoteTypeMapper.MapEntityToModel(record)); await this.mediator.Publish(new VoteTypeCreatedNotification(response.Record)); } return(response); }
public virtual async Task <UpdateResponse <ApiVoteTypeServerResponseModel> > Update( int id, ApiVoteTypeServerRequestModel model) { var validationResult = await this.VoteTypeModelValidator.ValidateUpdateAsync(id, model); if (validationResult.IsValid) { VoteType record = this.DalVoteTypeMapper.MapModelToEntity(id, model); await this.VoteTypeRepository.Update(record); record = await this.VoteTypeRepository.Get(id); ApiVoteTypeServerResponseModel apiModel = this.DalVoteTypeMapper.MapEntityToModel(record); await this.mediator.Publish(new VoteTypeUpdatedNotification(apiModel)); return(ValidationResponseFactory <ApiVoteTypeServerResponseModel> .UpdateResponse(apiModel)); } else { return(ValidationResponseFactory <ApiVoteTypeServerResponseModel> .UpdateResponse(validationResult)); } }