示例#1
0
        public EditViewModel(OpenEditWindowArgs args, IDataProvider dataProvider, IDialogService dialogService)
        {
            Args          = args;
            DataProvider  = dataProvider;
            DialogService = dialogService;

            switch (args.Type)
            {
            case ActionType.Add:
                CurrentFriend = new Friend {
                    Id = Guid.NewGuid().ToString(), BirthDate = new DateTime(1990, 1, 1)
                };
                break;

            case ActionType.Edit:
                // Clone a new object
                CurrentFriend = new Friend
                {
                    Id          = args.Friend.Id,
                    Name        = args.Friend.Name,
                    BirthDate   = args.Friend.BirthDate,
                    Email       = args.Friend.Email,
                    IsDeveloper = args.Friend.IsDeveloper
                };
                break;
            }

            SaveDataCommand = new RelayCommand(SaveData);
        }
示例#2
0
        public EditViewModel(OpenEditWindowArgs args, IDataProvider dataProvider, IDialogService dialogService)
        {
            Args          = args;
            DataProvider  = dataProvider;
            DialogService = dialogService;

            switch (args.Type)
            {
            case ActionType.Add:
                CurrentPersonal = new Personal {
                    ID = Guid.NewGuid().ToString(), Stunden = 0.0f
                };
                break;

            case ActionType.Edit:
                CurrentPersonal = new Personal {
                    ID              = args.Personal.ID,
                    MID             = args.Personal.MID,
                    Name            = args.Personal.Name,
                    VName           = args.Personal.VName,
                    Stunden         = args.Personal.Stunden,
                    IstUnterrichtet = args.Personal.IstUnterrichtet
                };
                break;
            }
            SaveDataCommand = new RelayCommand(SaveData);
        }
示例#3
0
        public void setup()
        {
            dataProvider = new Mock <IDataProvider>();

            openEditWindowArgs = new OpenEditWindowArgs();

            dialogService = new Mock <IDialogService>();
        }
示例#4
0
        public bool?ShowDialog(OpenEditWindowArgs args)
        {
            if (SimpleIoc.Default.ContainsCreated <OpenEditWindowArgs>())
            {
                SimpleIoc.Default.Unregister <OpenEditWindowArgs>();
            }
            SimpleIoc.Default.Register(() => args);
            EditWindow editWindow = new EditWindow();

            return(editWindow.ShowDialog());
        }
示例#5
0
        /// <summary>
        /// Show EditWindow
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public bool?ShowDialog(OpenEditWindowArgs args)
        {
            // If the container contains then target Type, then remove it firstly, or else an Exception will be thrown here
            if (SimpleIoc.Default.ContainsCreated <OpenEditWindowArgs>())
            {
                SimpleIoc.Default.Unregister <OpenEditWindowArgs>();
            }

            SimpleIoc.Default.Register(() => args);

            EditWindow editWindow = new EditWindow();

            return(editWindow.ShowDialog());
        }
示例#6
0
        public EditViewModel(OpenEditWindowArgs args, IDataProvider dataProvider, IDialogService dialogService)
        {
            Args          = args;
            DataProvider  = dataProvider;
            DialogService = dialogService;

            var c1 = new Contact {
                Id = Guid.NewGuid().ToString(), FirstName = "SpongeBob", LastName = "Squarepants", Birthday = new System.DateTime(2000, 3, 23), Company = "Krusty Krab", JobTitle = "Fry Cook", Email = "*****@*****.**", MobilePhone = "1234546430", Address = "Bikini Bottom"
            };
            var c2 = new Contact {
                Id = Guid.NewGuid().ToString(), FirstName = "Patrick", LastName = "Star", Birthday = new DateTime(2010, 3, 14), Company = "Unemployed", JobTitle = "none", Email = "*****@*****.**", MobilePhone = "1234567891", Address = "Under a rock"
            };

            SampleData = new ObservableCollection <Contact>();
            SampleData.Add(c1);
            SampleData.Add(c2);

            switch (args.Type)
            {
            case ActionType.Add:
                CurrentContact = new Contact {
                    Id = Guid.NewGuid().ToString()
                };
                break;

            case ActionType.Edit:
                //Clone a new object
                CurrentContact = new Contact
                {
                    Id          = args.Contact.Id,
                    FirstName   = args.Contact.FirstName,
                    LastName    = args.Contact.LastName,
                    Company     = args.Contact.Company,
                    Email       = args.Contact.Email,
                    Birthday    = args.Contact.Birthday,
                    JobTitle    = args.Contact.JobTitle,
                    Notes       = args.Contact.Notes,
                    MobilePhone = args.Contact.MobilePhone,
                    Address     = args.Contact.Address
                };
                break;
            }

            SaveDataCommand = new RelayCommand(SaveData);
        }