songjun
2024-09-04 cc908053e0b5075fbfd27350b6da4b39bca9e550
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using PalGain.Core;
using BatchService.Framework.Utility;
using sbcLabSystem.Service.QC;
 
namespace sbcLabSystem.Models.Backstage
{
    public class ApprovalDetailsPageViewModel
    {
        public ApprovalDetailsPageViewModel(int qcDistributionId)
        {
            var qcService = PalGainEngine.Instance.Resolve<QCService>();
            this.qcDistributionId = qcDistributionId;
            this.qcDistributionNo = qcService.GetQcDistributions()
                .FirstOrDefault(p => p.Id == qcDistributionId).DistNo;
            this.Approvals = qcService.GetApprovals()
                .Where(p => p.QCDistributionID == qcDistributionId).ToList()
                .Select(p => ApprovalInfoViewModel.FromEntity(p)).ToList();
            if (Approvals == null)
            {
                Approvals = new List<ApprovalInfoViewModel>();
            }
            this.QCDistributionList = new List<NameValues>();
            var qcDistList = qcService.GetQcDistributions().Where(p => p.Id != qcDistributionId).ToList()
                .Select(p => new
                {
                    p.Id,
                    p.DistNo,
                }).ToList();
            qcDistList.ForEach(x =>
            {
                QCDistributionList.Add(new NameValues()
                {
                    Id = x.Id,
                    Value = x.DistNo,
                });
            });
            if (QCDistributionList.Count > 0)
            {
                ImportQCDistributionId = QCDistributionList[0].Id;
            }
        }
        
        public ApprovalDetailsPageViewModel() { }
        public List<ApprovalInfoViewModel> Approvals { get; set; }
        public int qcDistributionId { get; set; }
        public string qcDistributionNo { get; set; }
 
        public class NameValues
        {
            public int Id { get; set; }
            public string Value { get; set; }
        }
        public List<NameValues> QCDistributionList { get; set; }
        public int ImportQCDistributionId { get; set; }
    }
}