Proyectos de Subversion Iphone Microlearning

Rev

| 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
25
{
26
    var points = [UserExtendedPoint]()
27
 
28
 
29
 
30
    init() {
31
        self.loadAll()
32
    }
33
 
34
    func loadAll() {
35
        points.removeAll()
36
 
37
        //let preference = Preference.sharedInstance
38
 
39
        let userExtendedDao = UserExtendedDao()
40
 
41
        let companyDao = CompanyDao()
42
        let companies = companyDao.selectAll();
43
 
44
        var i : Int = 0;
45
        var j : Int = 0;
46
 
47
        while i <  companies.count
48
        {
49
            let records = userExtendedDao.selectAllByCompanyUuid(companyUuid: companies[i].uuid)
50
            if records.count > 0 {
51
                points.append(UserExtendedPoint(type: .company , label: companies[i].name,  value: ""))
52
                while j <  records.count
53
                {
54
                    points.append(UserExtendedPoint(type: .data , label: records[j].label,  value: records[j].value))
55
                    j += 1
56
 
57
                }
58
 
59
            }
60
            i += 1
61
 
62
 
63
        }
64
 
65
 
66
 
67
 
68
 
69
    }
70
 
71
 
72
}