Proyectos de Subversion Iphone Microlearning - Inconcert

Rev

Rev 1 | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |

//
//  TopicCapsuleViewModel.swift
//  twogetskills
//
//  Created by Efrain Yanez Recanatini on 6/29/22.
//

import Foundation

class TopicCardViewModel: ObservableObject {

    @Published var topic = TopicModel()


    public func fetch(topicUuid: String, userUuid : String)
    {
        let topicDao = TopicDao()
        self.topic = topicDao.selectByUuid(uuid: topicUuid)
        self.fetchProgress(topicUuid: topicUuid, userUuid: userUuid)
    }
    
    public func fetchProgress(topicUuid: String, userUuid : String)
    {
        let progressDao = ProgressDao()
        let progress = progressDao.selectByTopicUuidAndUserUuid(topicUuid: topicUuid, userUuid: userUuid)
        if progress.id > 0 {
            self.topic.progress = progress.progress
            self.topic.completed = progress.completed
        }
    }
}