public virtual ApiCustomerCommunicationServerRequestModel MapServerResponseToRequest(
            ApiCustomerCommunicationServerResponseModel response)
        {
            var request = new ApiCustomerCommunicationServerRequestModel();

            request.SetProperties(
                response.CustomerId,
                response.DateCreated,
                response.EmployeeId,
                response.Notes);
            return(request);
        }
示例#2
0
        public void MapModelToEntity()
        {
            var mapper = new DALCustomerCommunicationMapper();
            ApiCustomerCommunicationServerRequestModel model = new ApiCustomerCommunicationServerRequestModel();

            model.SetProperties(1, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, "A");
            CustomerCommunication response = mapper.MapModelToEntity(1, model);

            response.CustomerId.Should().Be(1);
            response.DateCreated.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.EmployeeId.Should().Be(1);
            response.Notes.Should().Be("A");
        }
        public virtual ApiCustomerCommunicationServerResponseModel MapServerRequestToResponse(
            int id,
            ApiCustomerCommunicationServerRequestModel request)
        {
            var response = new ApiCustomerCommunicationServerResponseModel();

            response.SetProperties(id,
                                   request.CustomerId,
                                   request.DateCreated,
                                   request.EmployeeId,
                                   request.Notes);
            return(response);
        }
        public virtual CustomerCommunication MapModelToEntity(
            int id,
            ApiCustomerCommunicationServerRequestModel model
            )
        {
            CustomerCommunication item = new CustomerCommunication();

            item.SetProperties(
                id,
                model.CustomerId,
                model.DateCreated,
                model.EmployeeId,
                model.Notes);
            return(item);
        }
示例#5
0
        public virtual async Task <CreateResponse <ApiCustomerCommunicationServerResponseModel> > Create(
            ApiCustomerCommunicationServerRequestModel model)
        {
            CreateResponse <ApiCustomerCommunicationServerResponseModel> response = ValidationResponseFactory <ApiCustomerCommunicationServerResponseModel> .CreateResponse(await this.CustomerCommunicationModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                CustomerCommunication record = this.DalCustomerCommunicationMapper.MapModelToEntity(default(int), model);
                record = await this.CustomerCommunicationRepository.Create(record);

                response.SetRecord(this.DalCustomerCommunicationMapper.MapEntityToModel(record));
                await this.mediator.Publish(new CustomerCommunicationCreatedNotification(response.Record));
            }

            return(response);
        }
示例#6
0
        public virtual async Task <UpdateResponse <ApiCustomerCommunicationServerResponseModel> > Update(
            int id,
            ApiCustomerCommunicationServerRequestModel model)
        {
            var validationResult = await this.CustomerCommunicationModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                CustomerCommunication record = this.DalCustomerCommunicationMapper.MapModelToEntity(id, model);
                await this.CustomerCommunicationRepository.Update(record);

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

                ApiCustomerCommunicationServerResponseModel apiModel = this.DalCustomerCommunicationMapper.MapEntityToModel(record);
                await this.mediator.Publish(new CustomerCommunicationUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiCustomerCommunicationServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiCustomerCommunicationServerResponseModel> .UpdateResponse(validationResult));
            }
        }
        public JsonPatchDocument <ApiCustomerCommunicationServerRequestModel> CreatePatch(ApiCustomerCommunicationServerRequestModel model)
        {
            var patch = new JsonPatchDocument <ApiCustomerCommunicationServerRequestModel>();

            patch.Replace(x => x.CustomerId, model.CustomerId);
            patch.Replace(x => x.DateCreated, model.DateCreated);
            patch.Replace(x => x.EmployeeId, model.EmployeeId);
            patch.Replace(x => x.Notes, model.Notes);
            return(patch);
        }