Esempio n. 1
0
        public JsonPatchDocument <ApiVPersonServerRequestModel> CreatePatch(ApiVPersonServerRequestModel model)
        {
            var patch = new JsonPatchDocument <ApiVPersonServerRequestModel>();

            patch.Replace(x => x.PersonName, model.PersonName);
            return(patch);
        }
Esempio n. 2
0
		public void MapModelToEntity()
		{
			var mapper = new DALVPersonMapper();
			ApiVPersonServerRequestModel model = new ApiVPersonServerRequestModel();
			model.SetProperties("A");
			VPerson response = mapper.MapModelToEntity(1, model);

			response.PersonName.Should().Be("A");
		}
Esempio n. 3
0
        public virtual ApiVPersonServerRequestModel MapServerResponseToRequest(
            ApiVPersonServerResponseModel response)
        {
            var request = new ApiVPersonServerRequestModel();

            request.SetProperties(
                response.PersonName);
            return(request);
        }
Esempio n. 4
0
        public virtual ApiVPersonServerResponseModel MapServerRequestToResponse(
            int personId,
            ApiVPersonServerRequestModel request)
        {
            var response = new ApiVPersonServerResponseModel();

            response.SetProperties(personId,
                                   request.PersonName);
            return(response);
        }
Esempio n. 5
0
        public virtual VPerson MapModelToEntity(
            int personId,
            ApiVPersonServerRequestModel model
            )
        {
            VPerson item = new VPerson();

            item.SetProperties(
                personId,
                model.PersonName);
            return(item);
        }
Esempio n. 6
0
        public virtual async Task <CreateResponse <ApiVPersonServerResponseModel> > Create(
            ApiVPersonServerRequestModel model)
        {
            CreateResponse <ApiVPersonServerResponseModel> response = ValidationResponseFactory <ApiVPersonServerResponseModel> .CreateResponse(await this.VPersonModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                VPerson record = this.DalVPersonMapper.MapModelToEntity(default(int), model);
                record = await this.VPersonRepository.Create(record);

                response.SetRecord(this.DalVPersonMapper.MapEntityToModel(record));
                await this.mediator.Publish(new VPersonCreatedNotification(response.Record));
            }

            return(response);
        }
Esempio n. 7
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));
            }
        }