Example #1
0
        void OnCreateEditEntityViewModel(System.Object sender, DevExpress.Mvvm.Xpf.CreateEditItemViewModelArgs e)
        {
            var unitOfWork = new UnitOfWork();
            var item       = e.IsNewItem
                ? new Issue(unitOfWork)
                : unitOfWork.GetObjectByKey <Issue>(e.Key);

            e.ViewModel = new EditItemViewModel(
                item,
                new EditIssueInfo(unitOfWork, (IList)usersLookup.ItemsSource),
                dispose: () => unitOfWork.Dispose(),
                title: (e.IsNewItem ? "New " : "Edit ") + nameof(Issue)
                );
        }
        public void CreateEditEntityViewModel(DevExpress.Mvvm.Xpf.CreateEditItemViewModelArgs args)
        {
            var unitOfWork = new UnitOfWork();
            var item       = args.IsNewItem
                ? new Issue(unitOfWork)
                : unitOfWork.GetObjectByKey <Issue>(args.Key);

            args.ViewModel = new EditItemViewModel(
                item,
                new EditIssueInfo(unitOfWork, Users),
                dispose: () => unitOfWork.Dispose(),
                title: (args.IsNewItem ? "New " : "Edit ") + nameof(Issue)
                );
        }
Example #3
0
        void OnCreateEditEntityViewModel(System.Object sender, DevExpress.Mvvm.Xpf.CreateEditItemViewModelArgs e)
        {
            var  context = new DataClassesDataContext();
            Item item;

            if (e.IsNewItem)
            {
                item = new Item()
                {
                    Id = context.Items.Max(x => x.Id) + 1
                };
                context.Items.InsertOnSubmit(item);
            }
            else
            {
                var key = (int)e.Key;
                item = context.Items.Single(x => x.Id == key);
            }
            e.ViewModel = new EditItemViewModel(item, context);
        }
        void OnCreateEditEntityViewModel(System.Object sender, DevExpress.Mvvm.Xpf.CreateEditItemViewModelArgs e)
        {
            var   context = new IssuesContext();
            Issue item;

            if (e.IsNewItem)
            {
                item = new Issue()
                {
                    Created = DateTime.Now
                };
                context.Entry(item).State = EntityState.Added;
            }
            else
            {
                item = context.Issues.Find(e.Key);
            }
            e.ViewModel = new EditItemViewModel(
                item,
                new EditIssueInfo(context, (IList)usersLookup.ItemsSource),
                title: (e.IsNewItem ? "New " : "Edit ") + nameof(Issue)
                );
        }
        public void CreateEditEntityViewModel(DevExpress.Mvvm.Xpf.CreateEditItemViewModelArgs args)
        {
            var   context = new IssuesContext();
            Issue item;

            if (args.IsNewItem)
            {
                item = new Issue()
                {
                    Created = DateTime.Now
                };
                context.Entry(item).State = EntityState.Added;
            }
            else
            {
                item = context.Issues.Find(args.Key);
            }
            args.ViewModel = new EditItemViewModel(
                item,
                new EditIssueInfo(context, Users),
                title: (args.IsNewItem ? "New " : "Edit ") + nameof(Issue)
                );
        }