Blog.Logic.ObjectMapper.UserMapper.ToEntity C# (CSharp) Method

ToEntity() public static method

public static ToEntity ( User user ) : User
user User
return Blog.DataAccess.Database.Entities.Objects.User
        public static Db.User ToEntity(User user)
        {
            if (user != null)
            {
                var education = user.Education != null
                    ? user.Education.Select(EducationMapper.ToEntity).ToList()
                    : null;
                var hobbies = user.Hobbies != null
                    ? user.Hobbies.Select(HobbyMapper.ToEntity).ToList()
                    : null;
                var picture = user.Picture != null
                    ? (int?)user.Picture.Id
                    : null;
                var background = user.Background != null
                    ? (int?)user.Background.Id
                    : null;

                return new Db.User
                {
                    UserId = user.Id,
                    UserName = user.UserName,
                    IdentityId = user.IdentityId,
                    BirthDate = user.BirthDate,
                    FirstName = user.FirstName,
                    LastName = user.LastName,
                    EmailAddress = user.EmailAddress,
                    Address = user.Address != null ? AddressMapper.ToEntity(user.Address) : null,
                    Education = education,
                    Hobbies = hobbies,
                    PictureId = picture,
                    BackgroundId = background,
                    IsDeleted = user.IsDeleted
                };
            }
            return null;
        }
    }