public virtual ApiTagClientRequestModel MapServerResponseToClientRequest(
            ApiTagServerResponseModel response)
        {
            var request = new ApiTagClientRequestModel();

            request.SetProperties(
                response.Count,
                response.ExcerptPostId,
                response.TagName,
                response.WikiPostId);
            return(request);
        }
        public virtual ApiTagServerResponseModel MapServerRequestToResponse(
            int id,
            ApiTagServerRequestModel request)
        {
            var response = new ApiTagServerResponseModel();

            response.SetProperties(id,
                                   request.Count,
                                   request.ExcerptPostId,
                                   request.TagName,
                                   request.WikiPostId);
            return(response);
        }
Esempio n. 3
0
        public void MapEntityToModel()
        {
            var mapper = new DALTagMapper();
            Tag item   = new Tag();

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

            response.Count.Should().Be(1);
            response.ExcerptPostId.Should().Be(1);
            response.Id.Should().Be(1);
            response.TagName.Should().Be("A");
            response.WikiPostId.Should().Be(1);
        }
Esempio n. 4
0
        public virtual async Task <UpdateResponse <ApiTagServerResponseModel> > Update(
            int id,
            ApiTagServerRequestModel model)
        {
            var validationResult = await this.TagModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                Tag record = this.DalTagMapper.MapModelToEntity(id, model);
                await this.TagRepository.Update(record);

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

                ApiTagServerResponseModel apiModel = this.DalTagMapper.MapEntityToModel(record);
                await this.mediator.Publish(new TagUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiTagServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiTagServerResponseModel> .UpdateResponse(validationResult));
            }
        }
Esempio n. 5
0
        public virtual ApiTagServerResponseModel MapEntityToModel(
            Tag item)
        {
            var model = new ApiTagServerResponseModel();

            model.SetProperties(item.Id,
                                item.Count,
                                item.ExcerptPostId,
                                item.TagName,
                                item.WikiPostId);
            if (item.ExcerptPostIdNavigation != null)
            {
                var excerptPostIdModel = new ApiPostServerResponseModel();
                excerptPostIdModel.SetProperties(
                    item.ExcerptPostIdNavigation.Id,
                    item.ExcerptPostIdNavigation.AcceptedAnswerId,
                    item.ExcerptPostIdNavigation.AnswerCount,
                    item.ExcerptPostIdNavigation.Body,
                    item.ExcerptPostIdNavigation.ClosedDate,
                    item.ExcerptPostIdNavigation.CommentCount,
                    item.ExcerptPostIdNavigation.CommunityOwnedDate,
                    item.ExcerptPostIdNavigation.CreationDate,
                    item.ExcerptPostIdNavigation.FavoriteCount,
                    item.ExcerptPostIdNavigation.LastActivityDate,
                    item.ExcerptPostIdNavigation.LastEditDate,
                    item.ExcerptPostIdNavigation.LastEditorDisplayName,
                    item.ExcerptPostIdNavigation.LastEditorUserId,
                    item.ExcerptPostIdNavigation.OwnerUserId,
                    item.ExcerptPostIdNavigation.ParentId,
                    item.ExcerptPostIdNavigation.PostTypeId,
                    item.ExcerptPostIdNavigation.Score,
                    item.ExcerptPostIdNavigation.Tag,
                    item.ExcerptPostIdNavigation.Title,
                    item.ExcerptPostIdNavigation.ViewCount);

                model.SetExcerptPostIdNavigation(excerptPostIdModel);
            }

            if (item.WikiPostIdNavigation != null)
            {
                var wikiPostIdModel = new ApiPostServerResponseModel();
                wikiPostIdModel.SetProperties(
                    item.WikiPostIdNavigation.Id,
                    item.WikiPostIdNavigation.AcceptedAnswerId,
                    item.WikiPostIdNavigation.AnswerCount,
                    item.WikiPostIdNavigation.Body,
                    item.WikiPostIdNavigation.ClosedDate,
                    item.WikiPostIdNavigation.CommentCount,
                    item.WikiPostIdNavigation.CommunityOwnedDate,
                    item.WikiPostIdNavigation.CreationDate,
                    item.WikiPostIdNavigation.FavoriteCount,
                    item.WikiPostIdNavigation.LastActivityDate,
                    item.WikiPostIdNavigation.LastEditDate,
                    item.WikiPostIdNavigation.LastEditorDisplayName,
                    item.WikiPostIdNavigation.LastEditorUserId,
                    item.WikiPostIdNavigation.OwnerUserId,
                    item.WikiPostIdNavigation.ParentId,
                    item.WikiPostIdNavigation.PostTypeId,
                    item.WikiPostIdNavigation.Score,
                    item.WikiPostIdNavigation.Tag,
                    item.WikiPostIdNavigation.Title,
                    item.WikiPostIdNavigation.ViewCount);

                model.SetWikiPostIdNavigation(wikiPostIdModel);
            }

            return(model);
        }
Esempio n. 6
0
 public TagUpdatedNotification(ApiTagServerResponseModel record)
 {
     this.Record = record;
 }