public virtual ApiCustomerCommunicationClientRequestModel MapServerResponseToClientRequest(
            ApiCustomerCommunicationServerResponseModel response)
        {
            var request = new ApiCustomerCommunicationClientRequestModel();

            request.SetProperties(
                response.CustomerId,
                response.DateCreated,
                response.EmployeeId,
                response.Notes);
            return(request);
        }
        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);
        }
Example #3
0
        public void MapEntityToModel()
        {
            var mapper = new DALCustomerCommunicationMapper();
            CustomerCommunication item = new CustomerCommunication();

            item.SetProperties(1, 1, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, "A");
            ApiCustomerCommunicationServerResponseModel response = mapper.MapEntityToModel(item);

            response.CustomerId.Should().Be(1);
            response.DateCreated.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.EmployeeId.Should().Be(1);
            response.Id.Should().Be(1);
            response.Notes.Should().Be("A");
        }
        public virtual ApiCustomerCommunicationServerResponseModel MapEntityToModel(
            CustomerCommunication item)
        {
            var model = new ApiCustomerCommunicationServerResponseModel();

            model.SetProperties(item.Id,
                                item.CustomerId,
                                item.DateCreated,
                                item.EmployeeId,
                                item.Notes);
            if (item.CustomerIdNavigation != null)
            {
                var customerIdModel = new ApiCustomerServerResponseModel();
                customerIdModel.SetProperties(
                    item.CustomerIdNavigation.Id,
                    item.CustomerIdNavigation.Email,
                    item.CustomerIdNavigation.FirstName,
                    item.CustomerIdNavigation.LastName,
                    item.CustomerIdNavigation.Notes,
                    item.CustomerIdNavigation.Phone);

                model.SetCustomerIdNavigation(customerIdModel);
            }

            if (item.EmployeeIdNavigation != null)
            {
                var employeeIdModel = new ApiEmployeeServerResponseModel();
                employeeIdModel.SetProperties(
                    item.EmployeeIdNavigation.Id,
                    item.EmployeeIdNavigation.FirstName,
                    item.EmployeeIdNavigation.IsSalesPerson,
                    item.EmployeeIdNavigation.IsShipper,
                    item.EmployeeIdNavigation.LastName);

                model.SetEmployeeIdNavigation(employeeIdModel);
            }

            return(model);
        }
Example #5
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 CustomerCommunicationUpdatedNotification(ApiCustomerCommunicationServerResponseModel record)
 {
     this.Record = record;
 }