Пример #1
0
        public virtual ApiPipelineStepServerResponseModel MapEntityToModel(
            PipelineStep item)
        {
            var model = new ApiPipelineStepServerResponseModel();

            model.SetProperties(item.Id,
                                item.Name,
                                item.PipelineStepStatusId,
                                item.ShipperId);
            if (item.PipelineStepStatusIdNavigation != null)
            {
                var pipelineStepStatusIdModel = new ApiPipelineStepStatusServerResponseModel();
                pipelineStepStatusIdModel.SetProperties(
                    item.PipelineStepStatusIdNavigation.Id,
                    item.PipelineStepStatusIdNavigation.Name);

                model.SetPipelineStepStatusIdNavigation(pipelineStepStatusIdModel);
            }

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

                model.SetShipperIdNavigation(shipperIdModel);
            }

            return(model);
        }
Пример #2
0
        public virtual ApiEmployeeClientRequestModel MapServerResponseToClientRequest(
            ApiEmployeeServerResponseModel response)
        {
            var request = new ApiEmployeeClientRequestModel();

            request.SetProperties(
                response.FirstName,
                response.IsSalesPerson,
                response.IsShipper,
                response.LastName);
            return(request);
        }
Пример #3
0
        public virtual ApiEmployeeServerResponseModel MapEntityToModel(
            Employee item)
        {
            var model = new ApiEmployeeServerResponseModel();

            model.SetProperties(item.Id,
                                item.FirstName,
                                item.IsSalesPerson,
                                item.IsShipper,
                                item.LastName);

            return(model);
        }
Пример #4
0
        public virtual ApiEmployeeServerResponseModel MapServerRequestToResponse(
            int id,
            ApiEmployeeServerRequestModel request)
        {
            var response = new ApiEmployeeServerResponseModel();

            response.SetProperties(id,
                                   request.FirstName,
                                   request.IsSalesPerson,
                                   request.IsShipper,
                                   request.LastName);
            return(response);
        }
Пример #5
0
        public void MapEntityToModel()
        {
            var      mapper = new DALEmployeeMapper();
            Employee item   = new Employee();

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

            response.FirstName.Should().Be("A");
            response.Id.Should().Be(1);
            response.IsSalesPerson.Should().Be(true);
            response.IsShipper.Should().Be(true);
            response.LastName.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);
        }
Пример #7
0
        public virtual async Task <UpdateResponse <ApiEmployeeServerResponseModel> > Update(
            int id,
            ApiEmployeeServerRequestModel model)
        {
            var validationResult = await this.EmployeeModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                Employee record = this.DalEmployeeMapper.MapModelToEntity(id, model);
                await this.EmployeeRepository.Update(record);

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

                ApiEmployeeServerResponseModel apiModel = this.DalEmployeeMapper.MapEntityToModel(record);
                await this.mediator.Publish(new EmployeeUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiEmployeeServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiEmployeeServerResponseModel> .UpdateResponse(validationResult));
            }
        }
Пример #8
0
 public EmployeeUpdatedNotification(ApiEmployeeServerResponseModel record)
 {
     this.Record = record;
 }
 public void SetEmployeeIdNavigation(ApiEmployeeServerResponseModel value)
 {
     this.EmployeeIdNavigation = value;
 }