public virtual ApiTimestampCheckClientRequestModel MapServerResponseToClientRequest(
            ApiTimestampCheckServerResponseModel response)
        {
            var request = new ApiTimestampCheckClientRequestModel();

            request.SetProperties(
                response.Name,
                response.Timestamp);
            return(request);
        }
        public virtual ApiTimestampCheckServerResponseModel MapServerRequestToResponse(
            int id,
            ApiTimestampCheckServerRequestModel request)
        {
            var response = new ApiTimestampCheckServerResponseModel();

            response.SetProperties(id,
                                   request.Name,
                                   request.Timestamp);
            return(response);
        }
Пример #3
0
        public virtual ApiTimestampCheckServerResponseModel MapEntityToModel(
            TimestampCheck item)
        {
            var model = new ApiTimestampCheckServerResponseModel();

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

            return(model);
        }
Пример #4
0
        public void MapEntityToModel()
        {
            var            mapper = new DALTimestampCheckMapper();
            TimestampCheck item   = new TimestampCheck();

            item.SetProperties(1, "A", BitConverter.GetBytes(1));
            ApiTimestampCheckServerResponseModel response = mapper.MapEntityToModel(item);

            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
            response.Timestamp.Should().BeEquivalentTo(BitConverter.GetBytes(1));
        }
Пример #5
0
        public virtual async Task <UpdateResponse <ApiTimestampCheckServerResponseModel> > Update(
            int id,
            ApiTimestampCheckServerRequestModel model)
        {
            var validationResult = await this.TimestampCheckModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                TimestampCheck record = this.DalTimestampCheckMapper.MapModelToEntity(id, model);
                await this.TimestampCheckRepository.Update(record);

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

                ApiTimestampCheckServerResponseModel apiModel = this.DalTimestampCheckMapper.MapEntityToModel(record);
                await this.mediator.Publish(new TimestampCheckUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiTimestampCheckServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiTimestampCheckServerResponseModel> .UpdateResponse(validationResult));
            }
        }
Пример #6
0
 public TimestampCheckUpdatedNotification(ApiTimestampCheckServerResponseModel record)
 {
     this.Record = record;
 }