Esempio n. 1
0
        public virtual ApiReplyServerResponseModel MapEntityToModel(
            Reply item)
        {
            var model = new ApiReplyServerResponseModel();

            model.SetProperties(item.ReplyId,
                                item.Content,
                                item.Date,
                                item.ReplierUserId,
                                item.Time);
            if (item.ReplierUserIdNavigation != null)
            {
                var replierUserIdModel = new ApiUserServerResponseModel();
                replierUserIdModel.SetProperties(
                    item.ReplierUserIdNavigation.UserId,
                    item.ReplierUserIdNavigation.BioImgUrl,
                    item.ReplierUserIdNavigation.Birthday,
                    item.ReplierUserIdNavigation.ContentDescription,
                    item.ReplierUserIdNavigation.Email,
                    item.ReplierUserIdNavigation.FullName,
                    item.ReplierUserIdNavigation.HeaderImgUrl,
                    item.ReplierUserIdNavigation.Interest,
                    item.ReplierUserIdNavigation.LocationLocationId,
                    item.ReplierUserIdNavigation.Password,
                    item.ReplierUserIdNavigation.PhoneNumber,
                    item.ReplierUserIdNavigation.Privacy,
                    item.ReplierUserIdNavigation.Username,
                    item.ReplierUserIdNavigation.Website);

                model.SetReplierUserIdNavigation(replierUserIdModel);
            }

            return(model);
        }
        public virtual ApiReplyClientRequestModel MapServerResponseToClientRequest(
            ApiReplyServerResponseModel response)
        {
            var request = new ApiReplyClientRequestModel();

            request.SetProperties(
                response.Content,
                response.Date,
                response.ReplierUserId,
                response.Time);
            return(request);
        }
        public virtual ApiReplyServerResponseModel MapServerRequestToResponse(
            int replyId,
            ApiReplyServerRequestModel request)
        {
            var response = new ApiReplyServerResponseModel();

            response.SetProperties(replyId,
                                   request.Content,
                                   request.Date,
                                   request.ReplierUserId,
                                   request.Time);
            return(response);
        }
Esempio n. 4
0
        public void MapEntityToModel()
        {
            var   mapper = new DALReplyMapper();
            Reply item   = new Reply();

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

            response.Content.Should().Be("A");
            response.Date.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.ReplierUserId.Should().Be(1);
            response.ReplyId.Should().Be(1);
            response.Time.Should().Be(TimeSpan.Parse("01:00:00"));
        }
Esempio n. 5
0
        public virtual async Task <UpdateResponse <ApiReplyServerResponseModel> > Update(
            int replyId,
            ApiReplyServerRequestModel model)
        {
            var validationResult = await this.ReplyModelValidator.ValidateUpdateAsync(replyId, model);

            if (validationResult.IsValid)
            {
                Reply record = this.DalReplyMapper.MapModelToEntity(replyId, model);
                await this.ReplyRepository.Update(record);

                record = await this.ReplyRepository.Get(replyId);

                ApiReplyServerResponseModel apiModel = this.DalReplyMapper.MapEntityToModel(record);
                await this.mediator.Publish(new ReplyUpdatedNotification(apiModel));

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