コード例 #1
0
        public virtual ApiCustomerClientRequestModel MapServerResponseToClientRequest(
            ApiCustomerServerResponseModel response)
        {
            var request = new ApiCustomerClientRequestModel();

            request.SetProperties(
                response.Email,
                response.FirstName,
                response.LastName,
                response.Notes,
                response.Phone);
            return(request);
        }
コード例 #2
0
        public virtual ApiCustomerServerResponseModel MapEntityToModel(
            Customer item)
        {
            var model = new ApiCustomerServerResponseModel();

            model.SetProperties(item.Id,
                                item.Email,
                                item.FirstName,
                                item.LastName,
                                item.Notes,
                                item.Phone);

            return(model);
        }
コード例 #3
0
        public virtual ApiCustomerServerResponseModel MapServerRequestToResponse(
            int id,
            ApiCustomerServerRequestModel request)
        {
            var response = new ApiCustomerServerResponseModel();

            response.SetProperties(id,
                                   request.Email,
                                   request.FirstName,
                                   request.LastName,
                                   request.Notes,
                                   request.Phone);
            return(response);
        }
コード例 #4
0
        public void MapEntityToModel()
        {
            var      mapper = new DALCustomerMapper();
            Customer item   = new Customer();

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

            response.Email.Should().Be("A");
            response.FirstName.Should().Be("A");
            response.Id.Should().Be(1);
            response.LastName.Should().Be("A");
            response.Notes.Should().Be("A");
            response.Phone.Should().Be("A");
        }
コード例 #5
0
        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);
        }
コード例 #6
0
ファイル: CustomerService.cs プロジェクト: codenesium/samples
        public virtual async Task <UpdateResponse <ApiCustomerServerResponseModel> > Update(
            int id,
            ApiCustomerServerRequestModel model)
        {
            var validationResult = await this.CustomerModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                Customer record = this.DalCustomerMapper.MapModelToEntity(id, model);
                await this.CustomerRepository.Update(record);

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

                ApiCustomerServerResponseModel apiModel = this.DalCustomerMapper.MapEntityToModel(record);
                await this.mediator.Publish(new CustomerUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiCustomerServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiCustomerServerResponseModel> .UpdateResponse(validationResult));
            }
        }
コード例 #7
0
 public CustomerUpdatedNotification(ApiCustomerServerResponseModel record)
 {
     this.Record = record;
 }
コード例 #8
0
 public void SetCustomerIdNavigation(ApiCustomerServerResponseModel value)
 {
     this.CustomerIdNavigation = value;
 }