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

            patch.Replace(x => x.Note, model.Note);
            patch.Replace(x => x.PersonId, model.PersonId);
            patch.Replace(x => x.PersonTypeId, model.PersonTypeId);
            return(patch);
        }
Esempio n. 2
0
        public virtual ApiCallPersonServerRequestModel MapServerResponseToRequest(
            ApiCallPersonServerResponseModel response)
        {
            var request = new ApiCallPersonServerRequestModel();

            request.SetProperties(
                response.Note,
                response.PersonId,
                response.PersonTypeId);
            return(request);
        }
Esempio n. 3
0
        public virtual ApiCallPersonServerResponseModel MapServerRequestToResponse(
            int id,
            ApiCallPersonServerRequestModel request)
        {
            var response = new ApiCallPersonServerResponseModel();

            response.SetProperties(id,
                                   request.Note,
                                   request.PersonId,
                                   request.PersonTypeId);
            return(response);
        }
        public void MapModelToEntity()
        {
            var mapper = new DALCallPersonMapper();
            ApiCallPersonServerRequestModel model = new ApiCallPersonServerRequestModel();

            model.SetProperties("A", 1, 1);
            CallPerson response = mapper.MapModelToEntity(1, model);

            response.Note.Should().Be("A");
            response.PersonId.Should().Be(1);
            response.PersonTypeId.Should().Be(1);
        }
Esempio n. 5
0
        public virtual CallPerson MapModelToEntity(
            int id,
            ApiCallPersonServerRequestModel model
            )
        {
            CallPerson item = new CallPerson();

            item.SetProperties(
                id,
                model.Note,
                model.PersonId,
                model.PersonTypeId);
            return(item);
        }
Esempio n. 6
0
        public virtual async Task <CreateResponse <ApiCallPersonServerResponseModel> > Create(
            ApiCallPersonServerRequestModel model)
        {
            CreateResponse <ApiCallPersonServerResponseModel> response = ValidationResponseFactory <ApiCallPersonServerResponseModel> .CreateResponse(await this.CallPersonModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                CallPerson record = this.DalCallPersonMapper.MapModelToEntity(default(int), model);
                record = await this.CallPersonRepository.Create(record);

                response.SetRecord(this.DalCallPersonMapper.MapEntityToModel(record));
                await this.mediator.Publish(new CallPersonCreatedNotification(response.Record));
            }

            return(response);
        }
Esempio n. 7
0
        public virtual async Task <UpdateResponse <ApiCallPersonServerResponseModel> > Update(
            int id,
            ApiCallPersonServerRequestModel model)
        {
            var validationResult = await this.CallPersonModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                CallPerson record = this.DalCallPersonMapper.MapModelToEntity(id, model);
                await this.CallPersonRepository.Update(record);

                record = await this.CallPersonRepository.Get(id);

                ApiCallPersonServerResponseModel apiModel = this.DalCallPersonMapper.MapEntityToModel(record);
                await this.mediator.Publish(new CallPersonUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiCallPersonServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiCallPersonServerResponseModel> .UpdateResponse(validationResult));
            }
        }