예제 #1
0
        public static UserModel ParseUserEntityToModel(User entity)
        {
            UserModel userModelTemp = new UserModel();

            userModelTemp.Id = entity.Id;
            userModelTemp.FirstName = entity.FirstName;
            userModelTemp.LastName = entity.LastName;
            userModelTemp.Password = entity.Password;
            userModelTemp.Email = entity.Email;
            userModelTemp.Phone = entity.Phone;
            userModelTemp.DateOfBirth = entity.DateOfBirth.HasValue ? entity.DateOfBirth.Value.ToShortDateString() : null;
            userModelTemp.City = entity.City;
            userModelTemp.State = entity.State;
            userModelTemp.AccountType = entity.AccountType;
            userModelTemp.Gender = entity.Gender;
            userModelTemp.AboutMe = entity.AboutMe;
            userModelTemp.ProfilePicture = entity.ProfilePicture;

            if(entity.UserToken != null)
            userModelTemp.Token = entity.UserToken.Token;


            foreach (var u in entity.Friends)
            {
                userModelTemp.Friends.Add(ParseFriendEntityToModel(u));
            }

            foreach (var u in entity.FriendRequest)
            {
                userModelTemp.Friends.Add(ParseFriendRequestEntityToModel(u));
            }

            foreach (var w in entity.Post)
            {
                userModelTemp.Post.Add(ParseWallEntityToModel(w));
            }

            return userModelTemp;

        }
예제 #2
0
        public static User ParseUserModelToEntity(UserModel model)
        {
            var userEntityTemp = new User();

            userEntityTemp.Id = model.Id;
            userEntityTemp.FirstName = model.FirstName;
            userEntityTemp.LastName = model.LastName;
            userEntityTemp.Password = model.Password;
            userEntityTemp.Email = model.Email;
            userEntityTemp.Phone = model.Phone;
            if (!String.IsNullOrEmpty(model.DateOfBirth))
            {
                userEntityTemp.DateOfBirth = Convert.ToDateTime(model.DateOfBirth);
            }
            userEntityTemp.City = model.City;
            userEntityTemp.State = model.State;
            userEntityTemp.AccountType = model.AccountType;
            userEntityTemp.Gender = model.Gender;
            userEntityTemp.AboutMe = model.AboutMe;
            userEntityTemp.ProfilePicture = model.ProfilePicture;

            if(model.Token != null)
            userEntityTemp.UserToken.Token = model.Token;

            foreach (var u in model.Friends)
            {
                userEntityTemp.Friends.Add(ParseFriendModelToEntiy(u));
            }

            foreach (var w in model.Post)
            {
                userEntityTemp.Post.Add(ParseWallModelToEntity(w));
            }

            return userEntityTemp;
        }
예제 #3
0
 public TokenModel(User u)
 {
     user = u;
 }