aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/FSE/Tango.FSE.UI/Dialogs/BugReportViewVM.cs
blob: 0ba6a6c16e23c6433ecdf522126cfb0cd4f4f691 (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Core.DI;
using Tango.FSE.Common;
using Tango.FSE.Common.BugReporting;
using Tango.FSE.Common.Notifications;

namespace Tango.FSE.UI.Dialogs
{
    public class BugReportViewVM : FSEDialogViewVM
    {
        [TangoInject]
        private INotificationProvider NotificationProvider { get; set; }

        public Bug Bug { get; set; }
        public bool IsEditable { get; set; }

        private String _title;
        [Required(ErrorMessage = "Title is required")]
        public String Title
        {
            get { return _title; }
            set { _title = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); }
        }

        private String _description;
        public String Description
        {
            get { return _description; }
            set { _description = value; RaisePropertyChangedAuto(); }
        }

        private String _comments;
        public String Comments
        {
            get { return _comments; }
            set { _comments = value; RaisePropertyChangedAuto(); }
        }

        public BugReportViewVM()
        {
            TangoIOC.Default.Inject(this);
            IsEditable = true;
            Bug = new Bug();
            CanClose = true;
            OKText = "SUBMIT";
            HasDefault = false;
        }

        public BugReportViewVM(Bug bug) : this()
        {
            if (bug != null)
            {
                Bug = bug;
                Title = Bug.Title;
                Description = Bug.Description;
                IsEditable = false;
            }
        }

        protected override void Accept()
        {
            if (Validate())
            {
                Bug.Title = Title;
                Bug.Description = Description;
                Bug.Comments = Comments;

                base.Accept();
            }
        }
    }
}