示例#1
0
        public virtual ApiVPersonClientRequestModel MapServerResponseToClientRequest(
            ApiVPersonServerResponseModel response)
        {
            var request = new ApiVPersonClientRequestModel();

            request.SetProperties(
                response.PersonName);
            return(request);
        }
		public void MapEntityToModel()
		{
			var mapper = new DALVPersonMapper();
			VPerson item = new VPerson();
			item.SetProperties(1, "A");
			ApiVPersonServerResponseModel response = mapper.MapEntityToModel(item);

			response.PersonId.Should().Be(1);
			response.PersonName.Should().Be("A");
		}
示例#3
0
        public virtual ApiVPersonServerResponseModel MapServerRequestToResponse(
            int personId,
            ApiVPersonServerRequestModel request)
        {
            var response = new ApiVPersonServerResponseModel();

            response.SetProperties(personId,
                                   request.PersonName);
            return(response);
        }
示例#4
0
        public virtual ApiVPersonServerResponseModel MapEntityToModel(
            VPerson item)
        {
            var model = new ApiVPersonServerResponseModel();

            model.SetProperties(item.PersonId,
                                item.PersonName);

            return(model);
        }
示例#5
0
        public virtual async Task <UpdateResponse <ApiVPersonServerResponseModel> > Update(
            int personId,
            ApiVPersonServerRequestModel model)
        {
            var validationResult = await this.VPersonModelValidator.ValidateUpdateAsync(personId, model);

            if (validationResult.IsValid)
            {
                VPerson record = this.DalVPersonMapper.MapModelToEntity(personId, model);
                await this.VPersonRepository.Update(record);

                record = await this.VPersonRepository.Get(personId);

                ApiVPersonServerResponseModel apiModel = this.DalVPersonMapper.MapEntityToModel(record);
                await this.mediator.Publish(new VPersonUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiVPersonServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiVPersonServerResponseModel> .UpdateResponse(validationResult));
            }
        }
示例#6
0
 public VPersonUpdatedNotification(ApiVPersonServerResponseModel record)
 {
     this.Record = record;
 }