├── ZzaDashboard
├── ZzaDashboard
│ ├── zza-sample.png
│ ├── packages.config
│ ├── Properties
│ │ ├── Settings.settings
│ │ ├── Settings.Designer.cs
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ ├── DataSources
│ │ │ └── Zza.Data.Customer.datasource
│ │ └── Resources.resx
│ ├── ZzaDashboard.csproj.user
│ ├── App.xaml
│ ├── App.xaml.cs
│ ├── Services
│ │ ├── ICustomersRepository.cs
│ │ ├── IOrdersRepository.cs
│ │ ├── CustomersRepository.cs
│ │ └── OrdersRepository.cs
│ ├── MainWindow.xaml
│ ├── MainWindow.xaml.cs
│ ├── BindableBase.cs
│ ├── App.config
│ ├── ValidatableBindableBase.cs
│ ├── Customers
│ │ ├── CustomerEditView.xaml.cs
│ │ └── CustomerEditView.xaml
│ ├── RelayCommand.cs
│ └── ZzaDashboard.csproj
├── Zza.Data
│ ├── packages.config
│ ├── OrderStatus.cs
│ ├── ProductOption.cs
│ ├── ProductSize.cs
│ ├── OrderItemOption.cs
│ ├── Product.cs
│ ├── App.config
│ ├── Customer.cs
│ ├── OrderItem.cs
│ ├── Order.cs
│ ├── ZzaDbContext.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── DataModel.cd
│ └── Zza.Data.csproj
└── ZzaDashboard.sln
└── Readme.md
/ZzaDashboard/ZzaDashboard/zza-sample.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/briannoyes/WPFMVVM-StarterCode/HEAD/ZzaDashboard/ZzaDashboard/zza-sample.png
--------------------------------------------------------------------------------
/ZzaDashboard/Zza.Data/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ZzaDashboard/ZzaDashboard/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ZzaDashboard/ZzaDashboard/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/ZzaDashboard/ZzaDashboard/ZzaDashboard.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | ShowAllFiles
5 |
6 |
--------------------------------------------------------------------------------
/ZzaDashboard/Zza.Data/OrderStatus.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 |
5 | namespace Zza.Data
6 | {
7 | public class OrderStatus
8 | {
9 | public int Id { get; set; }
10 | public string Name { get; set; }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/ZzaDashboard/ZzaDashboard/App.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ZzaDashboard/ZzaDashboard/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 |
9 | namespace ZzaDashboard
10 | {
11 | ///
12 | /// Interaction logic for App.xaml
13 | ///
14 | public partial class App : Application
15 | {
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Readme.md:
--------------------------------------------------------------------------------
1 | This repo contains the starter code for my Pluralight Course WPF MVVM In Depth http://www.pluralsight.com/courses/wpf-mvvm-in-depth.
2 |
3 | To create the DB that the code depends on, create an empty database in your default SQL Server instance,
4 | and then open and execute the script ZzzDatabaseGen.sql. If you only have SQL Express installed or choose to create the
5 | database there, you will have to change the connection string in the app.config file for the app to point to
6 | .\SQLEXPRESS as the server name instead of just "."
--------------------------------------------------------------------------------
/ZzaDashboard/Zza.Data/ProductOption.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel.DataAnnotations;
4 | using System.Linq;
5 |
6 | namespace Zza.Data
7 | {
8 | public class ProductOption
9 | {
10 | [Key]
11 | public int Id { get; set; }
12 | public string Type { get; set; }
13 | public string Name { get; set; }
14 | public int Factor { get; set; }
15 | public bool IsPizzaOption { get; set; }
16 | public bool IsSaladOption { get; set; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/ZzaDashboard/Zza.Data/ProductSize.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Zza.Data
7 | {
8 | public class ProductSize
9 | {
10 | public int Id { get; set; }
11 | public string Type { get; set; }
12 | public string Name { get; set; }
13 | public decimal Price { get; set; }
14 | public decimal? PremiumPrice { get; set; }
15 | public decimal? ToppingPrice { get; set; }
16 | public bool? IsGlutenFree { get; set; }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/ZzaDashboard/ZzaDashboard/Services/ICustomersRepository.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Zza.Data;
6 |
7 | namespace ZzaDashboard.Services
8 | {
9 | public interface ICustomersRepository
10 | {
11 | Task> GetCustomersAsync();
12 | Task GetCustomerAsync(Guid id);
13 | Task AddCustomerAsync(Customer customer);
14 | Task UpdateCustomerAsync(Customer customer);
15 | Task DeleteCustomerAsync(Guid customerId);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/ZzaDashboard/Zza.Data/OrderItemOption.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 |
5 | namespace Zza.Data
6 | {
7 | public class OrderItemOption
8 | {
9 | public long Id { get; set; }
10 | public Guid? StoreId { get; set; }
11 | public long OrderItemId { get; set; }
12 | public int ProductOptionId { get; set; }
13 | public int Quantity { get; set; }
14 | public decimal Price { get; set; }
15 |
16 | public OrderItem OrderItem { get; set; }
17 | public ProductOption ProductOption { get; set; }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/ZzaDashboard/ZzaDashboard/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/ZzaDashboard/ZzaDashboard/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Shapes;
14 |
15 | namespace ZzaDashboard
16 | {
17 | ///
18 | /// Interaction logic for MainWindow.xaml
19 | ///
20 | public partial class MainWindow : Window
21 | {
22 | public MainWindow()
23 | {
24 | InitializeComponent();
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/ZzaDashboard/Zza.Data/Product.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel.DataAnnotations;
4 | using System.Linq;
5 |
6 | namespace Zza.Data
7 | {
8 | public class Product
9 | {
10 | [Key]
11 | public int Id { get; set; }
12 | public string Type { get; set; }
13 | public string Name { get; set; }
14 | public string Description { get; set; }
15 | public string Image { get; set; }
16 | public bool HasOptions { get; set; }
17 | public bool IsVegetarian { get; set; }
18 | public bool WithTomatoSauce { get; set; }
19 | public string SizeIds { get; set; }
20 | //[Timestamp]
21 | //public byte[] RowVersion { get; set; }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ZzaDashboard/ZzaDashboard/Services/IOrdersRepository.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using Zza.Data;
6 |
7 | namespace ZzaDashboard.Services
8 | {
9 | public interface IOrdersRepository
10 | {
11 | Task> GetOrdersForCustomersAsync(Guid customerId);
12 | Task> GetAllOrdersAsync();
13 | Task AddOrderAsync(Order order);
14 | Task UpdateOrderAsync(Order order);
15 | Task DeleteOrderAsync(int orderId);
16 |
17 | Task> GetProductsAsync();
18 | Task> GetProductOptionsAsync();
19 | Task> GetProductSizesAsync();
20 | Task> GetOrderStatusesAsync();
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/ZzaDashboard/Zza.Data/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/ZzaDashboard/Zza.Data/Customer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel.DataAnnotations;
4 | using System.Linq;
5 |
6 | namespace Zza.Data
7 | {
8 | public class Customer
9 | {
10 | public Customer()
11 | {
12 | Orders = new List();
13 | }
14 | [Key]
15 | public Guid Id { get; set; }
16 | public Guid? StoreId { get; set; }
17 | public string FirstName { get; set; }
18 | public string LastName { get; set; }
19 | public string FullName { get { return FirstName + " " + LastName; } }
20 | public string Phone { get; set; }
21 | public string Email { get; set; }
22 | public string Street { get; set; }
23 | public string City { get; set; }
24 | public string State { get; set; }
25 | public string Zip { get; set; }
26 | public List Orders { get; set; }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/ZzaDashboard/ZzaDashboard/BindableBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Linq;
5 | using System.Runtime.CompilerServices;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace ZzaDesktop
10 | {
11 | public class BindableBase : INotifyPropertyChanged
12 | {
13 | protected virtual void SetProperty(ref T member, T val,
14 | [CallerMemberName] string propertyName = null)
15 | {
16 | if (object.Equals(member, val)) return;
17 |
18 | member = val;
19 | PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
20 | }
21 |
22 | protected virtual void OnPropertyChanged(string propertyName)
23 | {
24 | PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
25 | }
26 | public event PropertyChangedEventHandler PropertyChanged = delegate { };
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/ZzaDashboard/Zza.Data/OrderItem.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel.DataAnnotations;
4 | using System.Linq;
5 |
6 | namespace Zza.Data
7 | {
8 | public class OrderItem
9 | {
10 | public OrderItem()
11 | {
12 | Options = new List();
13 | }
14 | [Key]
15 | public long Id { get; set; }
16 | public Guid? StoreId { get; set; }
17 | public long OrderId { get; set; }
18 | public int ProductId { get; set; }
19 | public int ProductSizeId { get; set; }
20 | public int Quantity { get; set; }
21 | public decimal UnitPrice { get; set; }
22 | public decimal TotalPrice { get; set; }
23 | public string Instructions { get; set; }
24 |
25 | public List Options { get; set; }
26 | public Product Product { get; set; }
27 | public Order Order { get; set; }
28 | public ProductSize Size { get; set; }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/ZzaDashboard/ZzaDashboard/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/ZzaDashboard/Zza.Data/Order.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel.DataAnnotations;
4 | using System.Linq;
5 |
6 | namespace Zza.Data
7 | {
8 | public class Order
9 | {
10 | public Order()
11 | {
12 | OrderItems = new List();
13 | }
14 | [Key]
15 | public long Id { get; set; }
16 | public Guid? StoreId { get; set; }
17 | public Guid CustomerId { get; set; }
18 | public int OrderStatusId { get; set; }
19 | public DateTime OrderDate { get; set; }
20 | public DateTime DeliveryDate { get; set; }
21 | public decimal DeliveryCharge { get; set; }
22 | public decimal ItemsTotal { get; set; }
23 | public string Phone { get; set; }
24 | public string DeliveryStreet { get; set; }
25 | public string DeliveryCity { get; set; }
26 | public string DeliveryState { get; set; }
27 | public string DeliveryZip { get; set; }
28 |
29 | //public Customer Customer { get; set; }
30 | public List OrderItems { get; set; }
31 | public OrderStatus Status { get; set; }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/ZzaDashboard/ZzaDashboard/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.0
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace ZzaDashboard.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/ZzaDashboard/Zza.Data/ZzaDbContext.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel.DataAnnotations.Schema;
4 | using System.Data.Entity;
5 | using System.Data.Entity.ModelConfiguration.Conventions;
6 | using System.Linq;
7 |
8 | namespace Zza.Data
9 | {
10 | public class ZzaDbContext : DbContext
11 | {
12 | public DbSet Customers { get; set; }
13 | public DbSet Orders { get; set; }
14 | public DbSet Products { get; set; }
15 | public DbSet OrderItems { get; set; }
16 | public DbSet OrderItemOptions { get; set; }
17 | public DbSet ProductOptions { get; set; }
18 | public DbSet ProductSizes { get; set; }
19 | public DbSet OrderStatuses { get; set; }
20 |
21 | protected override void OnModelCreating(DbModelBuilder modelBuilder)
22 | {
23 | // Table names match entity names by default (don't pluralize)
24 | modelBuilder.Conventions.Remove();
25 | // Globally disable the convention for cascading deletes
26 | modelBuilder.Conventions.Remove();
27 |
28 | modelBuilder.Entity()
29 | .Property(c => c.Id) // Client must set the ID.
30 | .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/ZzaDashboard/Zza.Data/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Zza.Data")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Zza.Data")]
13 | [assembly: AssemblyCopyright("Copyright © 2013")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("f1db1613-f6ea-42d6-bd44-9b9a012e76a0")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/ZzaDashboard/ZzaDashboard.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.31101.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZzaDashboard", "ZzaDashboard\ZzaDashboard.csproj", "{B4BAF275-1AAD-408E-AC04-1DBE32FD855E}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Zza.Data", "Zza.Data\Zza.Data.csproj", "{BB1E80DE-E6D1-4E29-BC2D-DB66B81163C5}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {B4BAF275-1AAD-408E-AC04-1DBE32FD855E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {B4BAF275-1AAD-408E-AC04-1DBE32FD855E}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {B4BAF275-1AAD-408E-AC04-1DBE32FD855E}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {B4BAF275-1AAD-408E-AC04-1DBE32FD855E}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {BB1E80DE-E6D1-4E29-BC2D-DB66B81163C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {BB1E80DE-E6D1-4E29-BC2D-DB66B81163C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {BB1E80DE-E6D1-4E29-BC2D-DB66B81163C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {BB1E80DE-E6D1-4E29-BC2D-DB66B81163C5}.Release|Any CPU.Build.0 = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/ZzaDashboard/ZzaDashboard/Services/CustomersRepository.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data.Entity;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using Zza.Data;
7 |
8 | namespace ZzaDashboard.Services
9 | {
10 | public class CustomersRepository : ICustomersRepository
11 | {
12 | ZzaDbContext _context = new ZzaDbContext();
13 |
14 | public Task> GetCustomersAsync()
15 | {
16 | return _context.Customers.ToListAsync();
17 | }
18 |
19 | public Task GetCustomerAsync(Guid id)
20 | {
21 | return _context.Customers.FirstOrDefaultAsync(c => c.Id == id);
22 | }
23 |
24 | public async Task AddCustomerAsync(Customer customer)
25 | {
26 | _context.Customers.Add(customer);
27 | await _context.SaveChangesAsync();
28 | return customer;
29 | }
30 |
31 | public async Task UpdateCustomerAsync(Customer customer)
32 | {
33 | if (!_context.Customers.Local.Any(c => c.Id == customer.Id))
34 | {
35 | _context.Customers.Attach(customer);
36 | }
37 | _context.Entry(customer).State = EntityState.Modified;
38 | await _context.SaveChangesAsync();
39 | return customer;
40 |
41 | }
42 |
43 | public async Task DeleteCustomerAsync(Guid customerId)
44 | {
45 | var customer = _context.Customers.FirstOrDefault(c => c.Id == customerId);
46 | if (customer != null)
47 | {
48 | _context.Customers.Remove(customer);
49 | }
50 | await _context.SaveChangesAsync();
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/ZzaDashboard/Zza.Data/DataModel.cd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | EAEAAAEAAAAACAAAAAAAAAAAAAAIQAAAAAAAAgAAAAg=
7 | Order.cs
8 |
9 |
10 |
11 |
12 |
13 | AAAAAEAAACAAAAAIAAAACAAAAAAAABACAAAAJAAAAAg=
14 | Customer.cs
15 |
16 |
17 |
18 |
19 |
20 | AAACAAAAAAAAAAAAAAAAAAAAAAQIAAAAAAABgAAAAAA=
21 | OrderItem.cs
22 |
23 |
24 |
25 |
26 |
27 | MAAAAAAAAAEAgAAAAAAAAAQAAAAAAAAAAAAAAAAAAAA=
28 | Product.cs
29 |
30 |
31 |
32 |
33 |
34 | IAAAAAAAAAAAAAAAAQAAAAQAAAAAAAAAAAAAAAAAAAA=
35 | ProductOption.cs
36 |
37 |
38 |
39 |
40 |
41 | AAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAgAQAAAA=
42 | ProductOptionItem.cs
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/ZzaDashboard/ZzaDashboard/ValidatableBindableBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.ComponentModel.DataAnnotations;
5 | using System.Linq;
6 | using System.Runtime.CompilerServices;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace ZzaDesktop
11 | {
12 | public class ValidatableBindableBase : BindableBase, INotifyDataErrorInfo
13 | {
14 | private Dictionary> _errors = new Dictionary>();
15 |
16 | public event EventHandler ErrorsChanged = delegate { };
17 |
18 | public System.Collections.IEnumerable GetErrors(string propertyName)
19 | {
20 | if (_errors.ContainsKey(propertyName))
21 | return _errors[propertyName];
22 | else
23 | return null;
24 | }
25 |
26 | public bool HasErrors
27 | {
28 | get { return _errors.Count > 0; }
29 | }
30 |
31 | protected override void SetProperty(ref T member, T val, [CallerMemberName] string propertyName = null)
32 | {
33 | base.SetProperty(ref member, val, propertyName);
34 | ValidateProperty(propertyName, val);
35 | }
36 |
37 | private void ValidateProperty(string propertyName, T value)
38 | {
39 | var results = new List();
40 | ValidationContext context = new ValidationContext(this);
41 | context.MemberName = propertyName;
42 | Validator.TryValidateProperty(value, context, results);
43 |
44 | if (results.Any())
45 | {
46 |
47 | _errors[propertyName] = results.Select(c => c.ErrorMessage).ToList();
48 | }
49 | else
50 | {
51 | _errors.Remove(propertyName);
52 | }
53 | ErrorsChanged(this, new DataErrorsChangedEventArgs(propertyName));
54 | }
55 |
56 |
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/ZzaDashboard/ZzaDashboard/Customers/CustomerEditView.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 | using System.Windows.Controls;
9 | using System.Windows.Data;
10 | using System.Windows.Documents;
11 | using System.Windows.Input;
12 | using System.Windows.Media;
13 | using System.Windows.Media.Imaging;
14 | using System.Windows.Navigation;
15 | using System.Windows.Shapes;
16 | using Zza.Data;
17 | using ZzaDashboard.Services;
18 |
19 | namespace ZzaDashboard.Customers
20 | {
21 | public partial class CustomerEditView : UserControl
22 | {
23 | private ICustomersRepository _repository = new CustomersRepository();
24 | private Customer _customer = null;
25 |
26 | public CustomerEditView()
27 | {
28 | InitializeComponent();
29 | }
30 |
31 | public Guid CustomerId
32 | {
33 | get { return (Guid)GetValue(CustomerIdProperty); }
34 | set { SetValue(CustomerIdProperty, value); }
35 | }
36 |
37 | public static readonly DependencyProperty CustomerIdProperty =
38 | DependencyProperty.Register("CustomerId", typeof(Guid),
39 | typeof(CustomerEditView), new PropertyMetadata(Guid.Empty));
40 |
41 | private async void OnLoaded(object sender, RoutedEventArgs e)
42 | {
43 | if (DesignerProperties.GetIsInDesignMode(this)) return;
44 |
45 | _customer = await _repository.GetCustomerAsync(CustomerId);
46 | if (_customer == null) return;
47 | firstNameTextBox.Text = _customer.FirstName;
48 | lastNameTextBox.Text = _customer.LastName;
49 | phoneTextBox.Text = _customer.Phone;
50 | }
51 |
52 | private async void OnSave(object sender, RoutedEventArgs e)
53 | {
54 | // TODO: Validate input... call business rules... etc...
55 | _customer.FirstName = firstNameTextBox.Text;
56 | _customer.LastName = lastNameTextBox.Text;
57 | _customer.Phone = phoneTextBox.Text;
58 | await _repository.UpdateCustomerAsync(_customer);
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/ZzaDashboard/ZzaDashboard/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // General Information about an assembly is controlled through the following
8 | // set of attributes. Change these attribute values to modify the information
9 | // associated with an assembly.
10 | [assembly: AssemblyTitle("ZzaDashboard")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("")]
14 | [assembly: AssemblyProduct("ZzaDashboard")]
15 | [assembly: AssemblyCopyright("Copyright © 2015")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // Setting ComVisible to false makes the types in this assembly not visible
20 | // to COM components. If you need to access a type in this assembly from
21 | // COM, set the ComVisible attribute to true on that type.
22 | [assembly: ComVisible(false)]
23 |
24 | //In order to begin building localizable applications, set
25 | //CultureYouAreCodingWith in your .csproj file
26 | //inside a . For example, if you are using US english
27 | //in your source files, set the to en-US. Then uncomment
28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
29 | //the line below to match the UICulture setting in the project file.
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
36 | //(used if a resource is not found in the page,
37 | // or application resource dictionaries)
38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
39 | //(used if a resource is not found in the page,
40 | // app, or any theme specific resource dictionaries)
41 | )]
42 |
43 |
44 | // Version information for an assembly consists of the following four values:
45 | //
46 | // Major Version
47 | // Minor Version
48 | // Build Number
49 | // Revision
50 | //
51 | // You can specify all the values or you can default the Build and Revision Numbers
52 | // by using the '*' as shown below:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/ZzaDashboard/ZzaDashboard/Services/OrdersRepository.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data.Entity;
4 | using System.Linq;
5 | using System.Threading.Tasks;
6 | using System.Transactions;
7 | using Zza.Data;
8 | namespace ZzaDashboard.Services
9 | {
10 | public class OrdersRepository : IOrdersRepository
11 | {
12 | ZzaDbContext _context = new ZzaDbContext();
13 |
14 | public async Task> GetOrdersForCustomersAsync(Guid customerId)
15 | {
16 | return await _context.Orders.Where(o => o.CustomerId == customerId).ToListAsync();
17 | }
18 |
19 | public async Task> GetAllOrdersAsync()
20 | {
21 | return await _context.Orders.ToListAsync();
22 | }
23 |
24 | public async Task AddOrderAsync(Order order)
25 | {
26 | _context.Orders.Add(order);
27 | await _context.SaveChangesAsync();
28 | return order;
29 | }
30 |
31 | public async Task UpdateOrderAsync(Order order)
32 | {
33 | if (!_context.Orders.Local.Any(o => o.Id == order.Id))
34 | {
35 | _context.Orders.Attach(order);
36 | }
37 | _context.Entry(order).State = EntityState.Modified;
38 | await _context.SaveChangesAsync();
39 | return order;
40 | }
41 |
42 | public async Task DeleteOrderAsync(int orderId)
43 | {
44 | using (TransactionScope scope = new TransactionScope())
45 | {
46 | var order = _context.Orders.Include("OrderItems").Include("OrderItems.OrderItemOptions").FirstOrDefault(o => o.Id == orderId);
47 | if (order != null)
48 | {
49 | foreach (OrderItem item in order.OrderItems)
50 | {
51 | foreach (var orderItemOption in item.Options)
52 | {
53 | _context.OrderItemOptions.Remove(orderItemOption);
54 | }
55 | _context.OrderItems.Remove(item);
56 | }
57 | _context.Orders.Remove(order);
58 | }
59 | await _context.SaveChangesAsync();
60 | scope.Complete();
61 | }
62 | }
63 |
64 |
65 | public async Task> GetProductsAsync()
66 | {
67 | return await _context.Products.ToListAsync();
68 | }
69 |
70 | public async Task> GetProductOptionsAsync()
71 | {
72 | return await _context.ProductOptions.ToListAsync();
73 | }
74 |
75 | public async Task> GetProductSizesAsync()
76 | {
77 | return await _context.ProductSizes.ToListAsync();
78 | }
79 |
80 | public async Task> GetOrderStatusesAsync()
81 | {
82 | return await _context.OrderStatuses.ToListAsync();
83 | }
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/ZzaDashboard/ZzaDashboard/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.0
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace ZzaDashboard.Properties
12 | {
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources()
34 | {
35 | }
36 |
37 | ///
38 | /// Returns the cached ResourceManager instance used by this class.
39 | ///
40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41 | internal static global::System.Resources.ResourceManager ResourceManager
42 | {
43 | get
44 | {
45 | if ((resourceMan == null))
46 | {
47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ZzaDashboard.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// Overrides the current thread's CurrentUICulture property for all
56 | /// resource lookups using this strongly typed resource class.
57 | ///
58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59 | internal static global::System.Globalization.CultureInfo Culture
60 | {
61 | get
62 | {
63 | return resourceCulture;
64 | }
65 | set
66 | {
67 | resourceCulture = value;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/ZzaDashboard/ZzaDashboard/Customers/CustomerEditView.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
31 |
39 |
45 |
53 |
59 |
67 |
73 |
77 |
78 |
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/ZzaDashboard/ZzaDashboard/RelayCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Windows.Input;
5 |
6 | namespace ZzaDashboard
7 | {
8 | public class RelayCommand : ICommand
9 | {
10 | Action _TargetExecuteMethod;
11 | Func _TargetCanExecuteMethod;
12 |
13 | public RelayCommand(Action executeMethod)
14 | {
15 | _TargetExecuteMethod = executeMethod;
16 | }
17 |
18 | public RelayCommand(Action executeMethod, Func canExecuteMethod)
19 | {
20 | _TargetExecuteMethod = executeMethod;
21 | _TargetCanExecuteMethod = canExecuteMethod;
22 | }
23 |
24 | public void RaiseCanExecuteChanged()
25 | {
26 | CanExecuteChanged(this, EventArgs.Empty);
27 | }
28 | #region ICommand Members
29 |
30 | bool ICommand.CanExecute(object parameter)
31 | {
32 | if (_TargetCanExecuteMethod != null)
33 | {
34 | return _TargetCanExecuteMethod();
35 | }
36 | if (_TargetExecuteMethod != null)
37 | {
38 | return true;
39 | }
40 | return false;
41 | }
42 |
43 | // Beware - should use weak references if command instance lifetime is longer than lifetime of UI objects that get hooked up to command
44 | // Prism commands solve this in their implementation
45 | public event EventHandler CanExecuteChanged = delegate { };
46 |
47 | void ICommand.Execute(object parameter)
48 | {
49 | if (_TargetExecuteMethod != null)
50 | {
51 | _TargetExecuteMethod();
52 | }
53 | }
54 | #endregion
55 | }
56 |
57 | public class RelayCommand : ICommand
58 | {
59 | Action _TargetExecuteMethod;
60 | Func _TargetCanExecuteMethod;
61 |
62 | public RelayCommand(Action executeMethod)
63 | {
64 | _TargetExecuteMethod = executeMethod;
65 | }
66 |
67 | public RelayCommand(Action executeMethod, Func canExecuteMethod)
68 | {
69 | _TargetExecuteMethod = executeMethod;
70 | _TargetCanExecuteMethod = canExecuteMethod;
71 | }
72 |
73 | public void RaiseCanExecuteChanged()
74 | {
75 | CanExecuteChanged(this, EventArgs.Empty);
76 | }
77 | #region ICommand Members
78 |
79 | bool ICommand.CanExecute(object parameter)
80 | {
81 | if (_TargetCanExecuteMethod != null)
82 | {
83 | T tparm = (T)parameter;
84 | return _TargetCanExecuteMethod(tparm);
85 | }
86 | if (_TargetExecuteMethod != null)
87 | {
88 | return true;
89 | }
90 | return false;
91 | }
92 |
93 | // Beware - should use weak references if command instance lifetime is longer than lifetime of UI objects that get hooked up to command
94 | // Prism commands solve this in their implementation
95 | public event EventHandler CanExecuteChanged = delegate { };
96 |
97 | void ICommand.Execute(object parameter)
98 | {
99 | if (_TargetExecuteMethod != null)
100 | {
101 | _TargetExecuteMethod((T)parameter);
102 | }
103 | }
104 | #endregion
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/ZzaDashboard/Zza.Data/Zza.Data.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {BB1E80DE-E6D1-4E29-BC2D-DB66B81163C5}
8 | Library
9 | Properties
10 | Zza.Data
11 | Zza.Data
12 | v4.5
13 | 512
14 | ..\
15 | true
16 |
17 |
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 | ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll
37 |
38 |
39 | ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll
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 |
76 |
--------------------------------------------------------------------------------
/ZzaDashboard/ZzaDashboard/Properties/DataSources/Zza.Data.Customer.datasource:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 | Zza.Data.Customer, Zza.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
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 |
--------------------------------------------------------------------------------
/ZzaDashboard/ZzaDashboard/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/ZzaDashboard/ZzaDashboard/ZzaDashboard.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {B4BAF275-1AAD-408E-AC04-1DBE32FD855E}
8 | WinExe
9 | Properties
10 | ZzaDashboard
11 | ZzaDashboard
12 | v4.5
13 | 512
14 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
15 | 4
16 | 12.0.51020.0
17 |
18 |
19 | AnyCPU
20 | true
21 | full
22 | false
23 | bin\Debug\
24 | DEBUG;TRACE
25 | prompt
26 | 4
27 |
28 |
29 | AnyCPU
30 | pdbonly
31 | true
32 | bin\Release\
33 | TRACE
34 | prompt
35 | 4
36 |
37 |
38 |
39 | ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll
40 |
41 |
42 | ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 | 4.0
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | MSBuild:Compile
65 | Designer
66 |
67 |
68 |
69 | CustomerEditView.xaml
70 |
71 |
72 | MainWindow.xaml
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | App.xaml
81 | Code
82 |
83 |
84 |
85 |
86 |
87 | Code
88 |
89 |
90 | True
91 | True
92 | Resources.resx
93 |
94 |
95 | True
96 | Settings.settings
97 | True
98 |
99 |
100 | ResXFileCodeGenerator
101 | Resources.Designer.cs
102 |
103 |
104 |
105 |
106 | SettingsSingleFileGenerator
107 | Settings.Designer.cs
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 | {bb1e80de-e6d1-4e29-bc2d-db66b81163c5}
117 | Zza.Data
118 |
119 |
120 |
121 |
122 | MSBuild:Compile
123 | Designer
124 |
125 |
126 | Designer
127 | MSBuild:Compile
128 |
129 |
130 |
131 |
138 |
--------------------------------------------------------------------------------