Proyectos de Subversion Iphone Microlearning - Inconcert

Rev

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

Rev Autor Línea Nro. Línea
1 efrain 1
//
2
//  UserExtendedViewModel.swift
3
//  twogetskills
4
//
5
//  Created by Efrain Yanez Recanatini on 5/6/22.
6
//
7
 
8
import Foundation
9
import SwiftUI
10
 
11
 
12
enum UserExtendedPointType {
13
    case company, data
14
}
15
 
16
struct UserExtendedPoint
17
{
18
    let type :  UserExtendedPointType
19
    let label : String
20
    let value : String
21
}
22
 
23
 
24
class UserExtendedPointViewModel : ObservableObject
25
{
26
    @Published var points = [UserExtendedPoint]()
27
 
28
 
29
 
30
    init() {
31
        self.loadAll()
32
    }
33
 
34
    func loadAll() {
35
        points.removeAll()
36
 
17 efrain 37
        let userExtendedDao = UserExtendedDao()
1 efrain 38
 
17 efrain 39
        let companyDao = CompanyDao()
1 efrain 40
        let companies = companyDao.selectAll();
41
 
42
        var i : Int = 0;
43
        var j : Int = 0;
44
 
45
        while i <  companies.count
46
        {
47
            let records = userExtendedDao.selectAllByCompanyUuid(companyUuid: companies[i].uuid)
48
            if records.count > 0 {
49
                points.append(UserExtendedPoint(type: .company , label: companies[i].name,  value: ""))
50
                while j <  records.count
51
                {
52
                    points.append(UserExtendedPoint(type: .data , label: records[j].label,  value: records[j].value))
53
                    j += 1
54
 
55
                }
56
 
57
            }
58
            i += 1
59
 
60
 
61
        }
62
 
63
 
64
 
65
 
66
 
67
    }
68
 
69
 
70
}