public virtual ApiCustomerClientRequestModel MapServerResponseToClientRequest( ApiCustomerServerResponseModel response) { var request = new ApiCustomerClientRequestModel(); request.SetProperties( response.Email, response.FirstName, response.LastName, response.Notes, response.Phone); return(request); }
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); }
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); }
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"); }
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); }
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)); } }
public CustomerUpdatedNotification(ApiCustomerServerResponseModel record) { this.Record = record; }
public void SetCustomerIdNavigation(ApiCustomerServerResponseModel value) { this.CustomerIdNavigation = value; }