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

            request.SetProperties(
                response.Name);
            return(request);
        }
コード例 #2
0
        public virtual ApiUnitDispositionServerResponseModel MapEntityToModel(
            UnitDisposition item)
        {
            var model = new ApiUnitDispositionServerResponseModel();

            model.SetProperties(item.Id,
                                item.Name);

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

            response.SetProperties(id,
                                   request.Name);
            return(response);
        }
コード例 #4
0
        public void MapEntityToModel()
        {
            var             mapper = new DALUnitDispositionMapper();
            UnitDisposition item   = new UnitDisposition();

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

            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
        }
コード例 #5
0
        public virtual async Task <UpdateResponse <ApiUnitDispositionServerResponseModel> > Update(
            int id,
            ApiUnitDispositionServerRequestModel model)
        {
            var validationResult = await this.UnitDispositionModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                UnitDisposition record = this.DalUnitDispositionMapper.MapModelToEntity(id, model);
                await this.UnitDispositionRepository.Update(record);

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

                ApiUnitDispositionServerResponseModel apiModel = this.DalUnitDispositionMapper.MapEntityToModel(record);
                await this.mediator.Publish(new UnitDispositionUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiUnitDispositionServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiUnitDispositionServerResponseModel> .UpdateResponse(validationResult));
            }
        }
コード例 #6
0
 public UnitDispositionUpdatedNotification(ApiUnitDispositionServerResponseModel record)
 {
     this.Record = record;
 }