Esempio n. 1
0
        public virtual ApiQuoteTweetClientRequestModel MapServerResponseToClientRequest(
            ApiQuoteTweetServerResponseModel response)
        {
            var request = new ApiQuoteTweetClientRequestModel();

            request.SetProperties(
                response.Content,
                response.Date,
                response.RetweeterUserId,
                response.SourceTweetId,
                response.Time);
            return(request);
        }
Esempio n. 2
0
        public virtual ApiQuoteTweetServerResponseModel MapServerRequestToResponse(
            int quoteTweetId,
            ApiQuoteTweetServerRequestModel request)
        {
            var response = new ApiQuoteTweetServerResponseModel();

            response.SetProperties(quoteTweetId,
                                   request.Content,
                                   request.Date,
                                   request.RetweeterUserId,
                                   request.SourceTweetId,
                                   request.Time);
            return(response);
        }
Esempio n. 3
0
        public virtual ApiQuoteTweetServerResponseModel MapEntityToModel(
            QuoteTweet item)
        {
            var model = new ApiQuoteTweetServerResponseModel();

            model.SetProperties(item.QuoteTweetId,
                                item.Content,
                                item.Date,
                                item.RetweeterUserId,
                                item.SourceTweetId,
                                item.Time);
            if (item.RetweeterUserIdNavigation != null)
            {
                var retweeterUserIdModel = new ApiUserServerResponseModel();
                retweeterUserIdModel.SetProperties(
                    item.RetweeterUserIdNavigation.UserId,
                    item.RetweeterUserIdNavigation.BioImgUrl,
                    item.RetweeterUserIdNavigation.Birthday,
                    item.RetweeterUserIdNavigation.ContentDescription,
                    item.RetweeterUserIdNavigation.Email,
                    item.RetweeterUserIdNavigation.FullName,
                    item.RetweeterUserIdNavigation.HeaderImgUrl,
                    item.RetweeterUserIdNavigation.Interest,
                    item.RetweeterUserIdNavigation.LocationLocationId,
                    item.RetweeterUserIdNavigation.Password,
                    item.RetweeterUserIdNavigation.PhoneNumber,
                    item.RetweeterUserIdNavigation.Privacy,
                    item.RetweeterUserIdNavigation.Username,
                    item.RetweeterUserIdNavigation.Website);

                model.SetRetweeterUserIdNavigation(retweeterUserIdModel);
            }

            if (item.SourceTweetIdNavigation != null)
            {
                var sourceTweetIdModel = new ApiTweetServerResponseModel();
                sourceTweetIdModel.SetProperties(
                    item.SourceTweetIdNavigation.TweetId,
                    item.SourceTweetIdNavigation.Content,
                    item.SourceTweetIdNavigation.Date,
                    item.SourceTweetIdNavigation.LocationId,
                    item.SourceTweetIdNavigation.Time,
                    item.SourceTweetIdNavigation.UserUserId);

                model.SetSourceTweetIdNavigation(sourceTweetIdModel);
            }

            return(model);
        }
        public void MapEntityToModel()
        {
            var        mapper = new DALQuoteTweetMapper();
            QuoteTweet item   = new QuoteTweet();

            item.SetProperties(1, "A", DateTime.Parse("1/1/1987 12:00:00 AM"), 1, 1, TimeSpan.Parse("01:00:00"));
            ApiQuoteTweetServerResponseModel response = mapper.MapEntityToModel(item);

            response.Content.Should().Be("A");
            response.Date.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.QuoteTweetId.Should().Be(1);
            response.RetweeterUserId.Should().Be(1);
            response.SourceTweetId.Should().Be(1);
            response.Time.Should().Be(TimeSpan.Parse("01:00:00"));
        }
Esempio n. 5
0
        public virtual async Task <UpdateResponse <ApiQuoteTweetServerResponseModel> > Update(
            int quoteTweetId,
            ApiQuoteTweetServerRequestModel model)
        {
            var validationResult = await this.QuoteTweetModelValidator.ValidateUpdateAsync(quoteTweetId, model);

            if (validationResult.IsValid)
            {
                QuoteTweet record = this.DalQuoteTweetMapper.MapModelToEntity(quoteTweetId, model);
                await this.QuoteTweetRepository.Update(record);

                record = await this.QuoteTweetRepository.Get(quoteTweetId);

                ApiQuoteTweetServerResponseModel apiModel = this.DalQuoteTweetMapper.MapEntityToModel(record);
                await this.mediator.Publish(new QuoteTweetUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiQuoteTweetServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiQuoteTweetServerResponseModel> .UpdateResponse(validationResult));
            }
        }
Esempio n. 6
0
 public QuoteTweetUpdatedNotification(ApiQuoteTweetServerResponseModel record)
 {
     this.Record = record;
 }