Example #1
0
        public virtual ApiPostHistoryTypeClientRequestModel MapServerResponseToClientRequest(
            ApiPostHistoryTypeServerResponseModel response)
        {
            var request = new ApiPostHistoryTypeClientRequestModel();

            request.SetProperties(
                response.RwType);
            return(request);
        }
Example #2
0
        public virtual ApiPostHistoryTypeServerResponseModel MapEntityToModel(
            PostHistoryType item)
        {
            var model = new ApiPostHistoryTypeServerResponseModel();

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

            return(model);
        }
Example #3
0
        public virtual ApiPostHistoryTypeServerResponseModel MapServerRequestToResponse(
            int id,
            ApiPostHistoryTypeServerRequestModel request)
        {
            var response = new ApiPostHistoryTypeServerResponseModel();

            response.SetProperties(id,
                                   request.RwType);
            return(response);
        }
Example #4
0
        public void MapEntityToModel()
        {
            var             mapper = new DALPostHistoryTypeMapper();
            PostHistoryType item   = new PostHistoryType();

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

            response.Id.Should().Be(1);
            response.RwType.Should().Be("A");
        }
Example #5
0
        public virtual async Task <UpdateResponse <ApiPostHistoryTypeServerResponseModel> > Update(
            int id,
            ApiPostHistoryTypeServerRequestModel model)
        {
            var validationResult = await this.PostHistoryTypeModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                PostHistoryType record = this.DalPostHistoryTypeMapper.MapModelToEntity(id, model);
                await this.PostHistoryTypeRepository.Update(record);

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

                ApiPostHistoryTypeServerResponseModel apiModel = this.DalPostHistoryTypeMapper.MapEntityToModel(record);
                await this.mediator.Publish(new PostHistoryTypeUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiPostHistoryTypeServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiPostHistoryTypeServerResponseModel> .UpdateResponse(validationResult));
            }
        }
Example #6
0
 public void SetPostHistoryTypeIdNavigation(ApiPostHistoryTypeServerResponseModel value)
 {
     this.PostHistoryTypeIdNavigation = value;
 }
 public PostHistoryTypeUpdatedNotification(ApiPostHistoryTypeServerResponseModel record)
 {
     this.Record = record;
 }
        public virtual ApiPostHistoryServerResponseModel MapEntityToModel(
            PostHistory item)
        {
            var model = new ApiPostHistoryServerResponseModel();

            model.SetProperties(item.Id,
                                item.Comment,
                                item.CreationDate,
                                item.PostHistoryTypeId,
                                item.PostId,
                                item.RevisionGUID,
                                item.Text,
                                item.UserDisplayName,
                                item.UserId);
            if (item.PostHistoryTypeIdNavigation != null)
            {
                var postHistoryTypeIdModel = new ApiPostHistoryTypeServerResponseModel();
                postHistoryTypeIdModel.SetProperties(
                    item.PostHistoryTypeIdNavigation.Id,
                    item.PostHistoryTypeIdNavigation.RwType);

                model.SetPostHistoryTypeIdNavigation(postHistoryTypeIdModel);
            }

            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.UserIdNavigation != null)
            {
                var userIdModel = new ApiUserServerResponseModel();
                userIdModel.SetProperties(
                    item.UserIdNavigation.Id,
                    item.UserIdNavigation.AboutMe,
                    item.UserIdNavigation.AccountId,
                    item.UserIdNavigation.Age,
                    item.UserIdNavigation.CreationDate,
                    item.UserIdNavigation.DisplayName,
                    item.UserIdNavigation.DownVote,
                    item.UserIdNavigation.EmailHash,
                    item.UserIdNavigation.LastAccessDate,
                    item.UserIdNavigation.Location,
                    item.UserIdNavigation.Reputation,
                    item.UserIdNavigation.UpVote,
                    item.UserIdNavigation.View,
                    item.UserIdNavigation.WebsiteUrl);

                model.SetUserIdNavigation(userIdModel);
            }

            return(model);
        }