public virtual ApiLinkTypeClientRequestModel MapServerResponseToClientRequest(
            ApiLinkTypeServerResponseModel response)
        {
            var request = new ApiLinkTypeClientRequestModel();

            request.SetProperties(
                response.RwType);
            return(request);
        }
Пример #2
0
        public virtual ApiLinkTypeServerResponseModel MapEntityToModel(
            LinkType item)
        {
            var model = new ApiLinkTypeServerResponseModel();

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

            return(model);
        }
        public virtual ApiLinkTypeServerResponseModel MapServerRequestToResponse(
            int id,
            ApiLinkTypeServerRequestModel request)
        {
            var response = new ApiLinkTypeServerResponseModel();

            response.SetProperties(id,
                                   request.RwType);
            return(response);
        }
Пример #4
0
        public void MapEntityToModel()
        {
            var      mapper = new DALLinkTypeMapper();
            LinkType item   = new LinkType();

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

            response.Id.Should().Be(1);
            response.RwType.Should().Be("A");
        }
Пример #5
0
        public virtual async Task <UpdateResponse <ApiLinkTypeServerResponseModel> > Update(
            int id,
            ApiLinkTypeServerRequestModel model)
        {
            var validationResult = await this.LinkTypeModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                LinkType record = this.DalLinkTypeMapper.MapModelToEntity(id, model);
                await this.LinkTypeRepository.Update(record);

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

                ApiLinkTypeServerResponseModel apiModel = this.DalLinkTypeMapper.MapEntityToModel(record);
                await this.mediator.Publish(new LinkTypeUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiLinkTypeServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiLinkTypeServerResponseModel> .UpdateResponse(validationResult));
            }
        }
Пример #6
0
        public virtual ApiPostLinkServerResponseModel MapEntityToModel(
            PostLink item)
        {
            var model = new ApiPostLinkServerResponseModel();

            model.SetProperties(item.Id,
                                item.CreationDate,
                                item.LinkTypeId,
                                item.PostId,
                                item.RelatedPostId);
            if (item.LinkTypeIdNavigation != null)
            {
                var linkTypeIdModel = new ApiLinkTypeServerResponseModel();
                linkTypeIdModel.SetProperties(
                    item.LinkTypeIdNavigation.Id,
                    item.LinkTypeIdNavigation.RwType);

                model.SetLinkTypeIdNavigation(linkTypeIdModel);
            }

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

                model.SetPostIdNavigation(postIdModel);
            }

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

                model.SetRelatedPostIdNavigation(relatedPostIdModel);
            }

            return(model);
        }
 public void SetLinkTypeIdNavigation(ApiLinkTypeServerResponseModel value)
 {
     this.LinkTypeIdNavigation = value;
 }
Пример #8
0
 public LinkTypeUpdatedNotification(ApiLinkTypeServerResponseModel record)
 {
     this.Record = record;
 }