Exemple #1
0
        public virtual ApiCallPersonServerResponseModel MapEntityToModel(
            CallPerson item)
        {
            var model = new ApiCallPersonServerResponseModel();

            model.SetProperties(item.Id,
                                item.Note,
                                item.PersonId,
                                item.PersonTypeId);
            if (item.PersonIdNavigation != null)
            {
                var personIdModel = new ApiPersonServerResponseModel();
                personIdModel.SetProperties(
                    item.PersonIdNavigation.Id,
                    item.PersonIdNavigation.FirstName,
                    item.PersonIdNavigation.LastName,
                    item.PersonIdNavigation.Phone,
                    item.PersonIdNavigation.Ssn);

                model.SetPersonIdNavigation(personIdModel);
            }

            if (item.PersonTypeIdNavigation != null)
            {
                var personTypeIdModel = new ApiPersonTypeServerResponseModel();
                personTypeIdModel.SetProperties(
                    item.PersonTypeIdNavigation.Id,
                    item.PersonTypeIdNavigation.Name);

                model.SetPersonTypeIdNavigation(personTypeIdModel);
            }

            return(model);
        }
Exemple #2
0
        public virtual ApiCallPersonClientRequestModel MapServerResponseToClientRequest(
            ApiCallPersonServerResponseModel response)
        {
            var request = new ApiCallPersonClientRequestModel();

            request.SetProperties(
                response.Note,
                response.PersonId,
                response.PersonTypeId);
            return(request);
        }
Exemple #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 MapEntityToModel()
        {
            var        mapper = new DALCallPersonMapper();
            CallPerson item   = new CallPerson();

            item.SetProperties(1, "A", 1, 1);
            ApiCallPersonServerResponseModel response = mapper.MapEntityToModel(item);

            response.Id.Should().Be(1);
            response.Note.Should().Be("A");
            response.PersonId.Should().Be(1);
            response.PersonTypeId.Should().Be(1);
        }
Exemple #5
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));
            }
        }
Exemple #6
0
 public CallPersonUpdatedNotification(ApiCallPersonServerResponseModel record)
 {
     this.Record = record;
 }