Exemple #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);
        }
Exemple #2
0
        public virtual ApiUserServerResponseModel MapEntityToModel(
            User item)
        {
            var model = new ApiUserServerResponseModel();

            model.SetProperties(item.UserId,
                                item.BioImgUrl,
                                item.Birthday,
                                item.ContentDescription,
                                item.Email,
                                item.FullName,
                                item.HeaderImgUrl,
                                item.Interest,
                                item.LocationLocationId,
                                item.Password,
                                item.PhoneNumber,
                                item.Privacy,
                                item.Username,
                                item.Website);
            if (item.LocationLocationIdNavigation != null)
            {
                var locationLocationIdModel = new ApiLocationServerResponseModel();
                locationLocationIdModel.SetProperties(
                    item.LocationLocationIdNavigation.LocationId,
                    item.LocationLocationIdNavigation.GpsLat,
                    item.LocationLocationIdNavigation.GpsLong,
                    item.LocationLocationIdNavigation.LocationName);

                model.SetLocationLocationIdNavigation(locationLocationIdModel);
            }

            return(model);
        }
Exemple #3
0
        public virtual ApiMessageServerResponseModel MapEntityToModel(
            Message item)
        {
            var model = new ApiMessageServerResponseModel();

            model.SetProperties(item.MessageId,
                                item.Content,
                                item.SenderUserId);
            if (item.SenderUserIdNavigation != null)
            {
                var senderUserIdModel = new ApiUserServerResponseModel();
                senderUserIdModel.SetProperties(
                    item.SenderUserIdNavigation.UserId,
                    item.SenderUserIdNavigation.BioImgUrl,
                    item.SenderUserIdNavigation.Birthday,
                    item.SenderUserIdNavigation.ContentDescription,
                    item.SenderUserIdNavigation.Email,
                    item.SenderUserIdNavigation.FullName,
                    item.SenderUserIdNavigation.HeaderImgUrl,
                    item.SenderUserIdNavigation.Interest,
                    item.SenderUserIdNavigation.LocationLocationId,
                    item.SenderUserIdNavigation.Password,
                    item.SenderUserIdNavigation.PhoneNumber,
                    item.SenderUserIdNavigation.Privacy,
                    item.SenderUserIdNavigation.Username,
                    item.SenderUserIdNavigation.Website);

                model.SetSenderUserIdNavigation(senderUserIdModel);
            }

            return(model);
        }
Exemple #4
0
        public virtual ApiFollowerServerResponseModel MapEntityToModel(
            Follower item)
        {
            var model = new ApiFollowerServerResponseModel();

            model.SetProperties(item.Id,
                                item.Blocked,
                                item.DateFollowed,
                                item.FollowedUserId,
                                item.FollowingUserId,
                                item.FollowRequestStatu,
                                item.Muted);
            if (item.FollowedUserIdNavigation != null)
            {
                var followedUserIdModel = new ApiUserServerResponseModel();
                followedUserIdModel.SetProperties(
                    item.FollowedUserIdNavigation.UserId,
                    item.FollowedUserIdNavigation.BioImgUrl,
                    item.FollowedUserIdNavigation.Birthday,
                    item.FollowedUserIdNavigation.ContentDescription,
                    item.FollowedUserIdNavigation.Email,
                    item.FollowedUserIdNavigation.FullName,
                    item.FollowedUserIdNavigation.HeaderImgUrl,
                    item.FollowedUserIdNavigation.Interest,
                    item.FollowedUserIdNavigation.LocationLocationId,
                    item.FollowedUserIdNavigation.Password,
                    item.FollowedUserIdNavigation.PhoneNumber,
                    item.FollowedUserIdNavigation.Privacy,
                    item.FollowedUserIdNavigation.Username,
                    item.FollowedUserIdNavigation.Website);

                model.SetFollowedUserIdNavigation(followedUserIdModel);
            }

            if (item.FollowingUserIdNavigation != null)
            {
                var followingUserIdModel = new ApiUserServerResponseModel();
                followingUserIdModel.SetProperties(
                    item.FollowingUserIdNavigation.UserId,
                    item.FollowingUserIdNavigation.BioImgUrl,
                    item.FollowingUserIdNavigation.Birthday,
                    item.FollowingUserIdNavigation.ContentDescription,
                    item.FollowingUserIdNavigation.Email,
                    item.FollowingUserIdNavigation.FullName,
                    item.FollowingUserIdNavigation.HeaderImgUrl,
                    item.FollowingUserIdNavigation.Interest,
                    item.FollowingUserIdNavigation.LocationLocationId,
                    item.FollowingUserIdNavigation.Password,
                    item.FollowingUserIdNavigation.PhoneNumber,
                    item.FollowingUserIdNavigation.Privacy,
                    item.FollowingUserIdNavigation.Username,
                    item.FollowingUserIdNavigation.Website);

                model.SetFollowingUserIdNavigation(followingUserIdModel);
            }

            return(model);
        }
        public virtual ApiUserClientRequestModel MapServerResponseToClientRequest(
            ApiUserServerResponseModel response)
        {
            var request = new ApiUserClientRequestModel();

            request.SetProperties(
                response.BioImgUrl,
                response.Birthday,
                response.ContentDescription,
                response.Email,
                response.FullName,
                response.HeaderImgUrl,
                response.Interest,
                response.LocationLocationId,
                response.Password,
                response.PhoneNumber,
                response.Privacy,
                response.Username,
                response.Website);
            return(request);
        }
        public virtual ApiUserServerResponseModel MapServerRequestToResponse(
            int userId,
            ApiUserServerRequestModel request)
        {
            var response = new ApiUserServerResponseModel();

            response.SetProperties(userId,
                                   request.BioImgUrl,
                                   request.Birthday,
                                   request.ContentDescription,
                                   request.Email,
                                   request.FullName,
                                   request.HeaderImgUrl,
                                   request.Interest,
                                   request.LocationLocationId,
                                   request.Password,
                                   request.PhoneNumber,
                                   request.Privacy,
                                   request.Username,
                                   request.Website);
            return(response);
        }
        public void MapEntityToModel()
        {
            var  mapper = new DALUserMapper();
            User item   = new User();

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

            response.BioImgUrl.Should().Be("A");
            response.Birthday.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.ContentDescription.Should().Be("A");
            response.Email.Should().Be("A");
            response.FullName.Should().Be("A");
            response.HeaderImgUrl.Should().Be("A");
            response.Interest.Should().Be("A");
            response.LocationLocationId.Should().Be(1);
            response.Password.Should().Be("A");
            response.PhoneNumber.Should().Be("A");
            response.Privacy.Should().Be("A");
            response.UserId.Should().Be(1);
            response.Username.Should().Be("A");
            response.Website.Should().Be("A");
        }
Exemple #8
0
        public virtual async Task <UpdateResponse <ApiUserServerResponseModel> > Update(
            int userId,
            ApiUserServerRequestModel model)
        {
            var validationResult = await this.UserModelValidator.ValidateUpdateAsync(userId, model);

            if (validationResult.IsValid)
            {
                User record = this.DalUserMapper.MapModelToEntity(userId, model);
                await this.UserRepository.Update(record);

                record = await this.UserRepository.Get(userId);

                ApiUserServerResponseModel apiModel = this.DalUserMapper.MapEntityToModel(record);
                await this.mediator.Publish(new UserUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiUserServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiUserServerResponseModel> .UpdateResponse(validationResult));
            }
        }
Exemple #9
0
 public void SetUserUserIdNavigation(ApiUserServerResponseModel value)
 {
     this.UserUserIdNavigation = value;
 }
Exemple #10
0
 public UserUpdatedNotification(ApiUserServerResponseModel record)
 {
     this.Record = record;
 }
 public void SetFollowingUserIdNavigation(ApiUserServerResponseModel value)
 {
     this.FollowingUserIdNavigation = value;
 }