aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.BL/Entities/Dispenser.cs
blob: 2508ec121180856c95bd7902f61318b62e1d37a2 (plain)
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
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tango.BL.Entities
{
    public partial class Dispenser : DispenserBase
    {
        [JsonIgnore]
        [NotMapped]
        public bool IsInstalled
        {
            get
            {
                return IdsPacks != null && IdsPacks.Count > 0;
            }
        }

        [JsonIgnore]
        [NotMapped]
        public Machine Machine { get; private set; }

        public async void InitMachine(ObservablesContext context)
        {
            if (IdsPacks != null && IdsPacks.Count > 0)
            {
                var config_guid = IdsPacks[0].ConfigurationGuid;
                Machine = await context.Machines.SingleOrDefaultAsync(x => x.ConfigurationGuid == config_guid);
                RaisePropertyChanged(nameof(Machine));
            }
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Dispenser" /> class.
        /// </summary>
        public Dispenser() : base()
        {

        }
    }
}