public virtual ApiClaspClientRequestModel MapServerResponseToClientRequest(
            ApiClaspServerResponseModel response)
        {
            var request = new ApiClaspClientRequestModel();

            request.SetProperties(
                response.NextChainId,
                response.PreviousChainId);
            return(request);
        }
        public virtual ApiClaspServerResponseModel MapServerRequestToResponse(
            int id,
            ApiClaspServerRequestModel request)
        {
            var response = new ApiClaspServerResponseModel();

            response.SetProperties(id,
                                   request.NextChainId,
                                   request.PreviousChainId);
            return(response);
        }
        public void MapEntityToModel()
        {
            var   mapper = new DALClaspMapper();
            Clasp item   = new Clasp();

            item.SetProperties(1, 1, 1);
            ApiClaspServerResponseModel response = mapper.MapEntityToModel(item);

            response.Id.Should().Be(1);
            response.NextChainId.Should().Be(1);
            response.PreviousChainId.Should().Be(1);
        }
Beispiel #4
0
        public virtual async Task <UpdateResponse <ApiClaspServerResponseModel> > Update(
            int id,
            ApiClaspServerRequestModel model)
        {
            var validationResult = await this.ClaspModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                Clasp record = this.DalClaspMapper.MapModelToEntity(id, model);
                await this.ClaspRepository.Update(record);

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

                ApiClaspServerResponseModel apiModel = this.DalClaspMapper.MapEntityToModel(record);
                await this.mediator.Publish(new ClaspUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiClaspServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiClaspServerResponseModel> .UpdateResponse(validationResult));
            }
        }
Beispiel #5
0
        public virtual ApiClaspServerResponseModel MapEntityToModel(
            Clasp item)
        {
            var model = new ApiClaspServerResponseModel();

            model.SetProperties(item.Id,
                                item.NextChainId,
                                item.PreviousChainId);
            if (item.NextChainIdNavigation != null)
            {
                var nextChainIdModel = new ApiChainServerResponseModel();
                nextChainIdModel.SetProperties(
                    item.NextChainIdNavigation.Id,
                    item.NextChainIdNavigation.ChainStatusId,
                    item.NextChainIdNavigation.ExternalId,
                    item.NextChainIdNavigation.Name,
                    item.NextChainIdNavigation.TeamId);

                model.SetNextChainIdNavigation(nextChainIdModel);
            }

            if (item.PreviousChainIdNavigation != null)
            {
                var previousChainIdModel = new ApiChainServerResponseModel();
                previousChainIdModel.SetProperties(
                    item.PreviousChainIdNavigation.Id,
                    item.PreviousChainIdNavigation.ChainStatusId,
                    item.PreviousChainIdNavigation.ExternalId,
                    item.PreviousChainIdNavigation.Name,
                    item.PreviousChainIdNavigation.TeamId);

                model.SetPreviousChainIdNavigation(previousChainIdModel);
            }

            return(model);
        }
Beispiel #6
0
 public ClaspUpdatedNotification(ApiClaspServerResponseModel record)
 {
     this.Record = record;
 }