Пример #1
0
        public static School.Business.UserClass ToBusinessModel(this School.Repository.UserClass repositoryObject, IUserRepository userRepository, IClassRepository classRepository)
        {
            var targetUser  = userRepository.User(repositoryObject.UserId).ToBusinessModel();
            var targetClass = classRepository.Class(repositoryObject.ClassId).ToBusinessModel();

            return(new UserClass()
            {
                ClassId = repositoryObject.ClassId,
                UserId = repositoryObject.UserId,
                Class = targetClass,
                User = targetUser
            });
        }
        public static School.Database.Models.UserClass ToDbModel(this School.Repository.UserClass repositoryObject)
        {
            var targetUser  = DatabaseAccessor.Instance.User.FirstOrDefault(t => t.UserId == repositoryObject.UserId);
            var targetClass = DatabaseAccessor.Instance.Class.FirstOrDefault(t => t.ClassId == repositoryObject.ClassId);

            return(new Database.Models.UserClass()
            {
                Class = targetClass,
                ClassId = targetClass.ClassId,
                User = targetUser,
                UserId = targetUser.UserId
            });
        }