aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.CodeGeneration/Templates/EntityCodeFile.cshtml
blob: 709da7dda0c1ac0d2dd64d1617d4cd6ad7796cb9 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Tango.DAL.Remote.DB;

namespace Tango.DAL.Observables
{
    [EntityFieldName("@(Model.TableName)")]
    public partial class @(Model.Name) : ObservableEntity<@(Model.EntityName)>
    {
        @foreach (var prop in Model.Fields)
        {
    <div>
        private @(prop.Type) _@(prop.Name.ToLower());
        /// <summary>
        /// Gets or sets the @(Model.Name.ToLower()) @(prop.Description).
        /// </summary>
        [EntityFieldName("@(prop.FieldName)")]
        public @(prop.Type) @(prop.Name)
        {
            get { return _@(prop.Name.ToLower()); }
            set { _@(prop.Name.ToLower()) = value; RaisePropertyChanged(nameof(@(prop.Name))); }
        }
    </div>
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="@(Model.Name)" /> class.
        /// </summary>
        public @(Model.Name)() : base()
        {
            Init();
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="@(Model.Name)" /> class.
        /// </summary>
        /// <param name="entity">The entity.</param>
        public @(Model.Name)(@(Model.EntityName) entity) : base(entity)
        {
            Init();
            MapEntityToObservable(entity, this);
        }

        /// <summary>
        /// Initialize complex types.
        /// </summary>
        private void Init()
        {
            @foreach (var prop in Model.Fields)
            {
                if (prop.Construct)
                { 
                <div>
                    @(prop.Name) = new @(prop.Type)();
                </div>
                }
            }
        }
    }
}