diff --git a/Tundra Core/Account.cs b/Tundra Core/Account.cs
new file mode 100644
index 0000000..e4963af
--- /dev/null
+++ b/Tundra Core/Account.cs
@@ -0,0 +1,29 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated from a template.
+//
+// Manual changes to this file may cause unexpected behavior in your application.
+// Manual changes to this file will be overwritten if the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace TundraCore
+{
+ using System;
+ using System.Collections.Generic;
+
+ public abstract partial class Account
+ {
+ public int Id { get; set; }
+ public string Name { get; set; }
+ public decimal Balance { get; set; }
+ public int UserId { get; set; }
+
+ public virtual User User { get; set; }
+
+ public override string ToString()
+ {
+ return Name + " | $" + Balance;
+ }
+ }
+}
diff --git a/Tundra Core/CheckingAccount.cs b/Tundra Core/CheckingAccount.cs
new file mode 100644
index 0000000..3e653ae
--- /dev/null
+++ b/Tundra Core/CheckingAccount.cs
@@ -0,0 +1,18 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated from a template.
+//
+// Manual changes to this file may cause unexpected behavior in your application.
+// Manual changes to this file will be overwritten if the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace TundraCore
+{
+ using System;
+ using System.Collections.Generic;
+
+ public partial class CheckingAccount : Account
+ {
+ }
+}
diff --git a/Tundra Core/Expense.cs b/Tundra Core/Expense.cs
new file mode 100644
index 0000000..ac49833
--- /dev/null
+++ b/Tundra Core/Expense.cs
@@ -0,0 +1,18 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated from a template.
+//
+// Manual changes to this file may cause unexpected behavior in your application.
+// Manual changes to this file will be overwritten if the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace TundraCore
+{
+ using System;
+ using System.Collections.Generic;
+
+ public partial class Expense : Transaction
+ {
+ }
+}
diff --git a/Tundra Core/Goal.cs b/Tundra Core/Goal.cs
new file mode 100644
index 0000000..fc92bd3
--- /dev/null
+++ b/Tundra Core/Goal.cs
@@ -0,0 +1,41 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated from a template.
+//
+// Manual changes to this file may cause unexpected behavior in your application.
+// Manual changes to this file will be overwritten if the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace TundraCore
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Text;
+
+ public partial class Goal
+ {
+ public int Id { get; set; }
+ public string Name { get; set; }
+ public string Description { get; set; }
+ public decimal TargetAmount { get; set; }
+ public decimal AcruedAmount { get; set; }
+ public decimal ContributionAmount { get; set; }
+ public bool Accomplished { get; set; }
+ public System.DateTime Created { get; set; }
+ public System.DateTime Deadline { get; set; }
+ public System.DateTime Modified { get; set; }
+ public int UserId { get; set; }
+
+ public virtual User User { get; set; }
+
+ public override string ToString()
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.Append(Name + " | ");
+ sb.Append(Description);
+
+ return sb.ToString();
+ }
+ }
+}
diff --git a/Tundra Core/Income.cs b/Tundra Core/Income.cs
new file mode 100644
index 0000000..8845c20
--- /dev/null
+++ b/Tundra Core/Income.cs
@@ -0,0 +1,18 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated from a template.
+//
+// Manual changes to this file may cause unexpected behavior in your application.
+// Manual changes to this file will be overwritten if the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace TundraCore
+{
+ using System;
+ using System.Collections.Generic;
+
+ public partial class Income : Transaction
+ {
+ }
+}
diff --git a/Tundra Core/Properties/AssemblyInfo.cs b/Tundra Core/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..2ba566b
--- /dev/null
+++ b/Tundra Core/Properties/AssemblyInfo.cs
@@ -0,0 +1,41 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+
+[assembly: AssemblyTitle("Tundra")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("TundraCore")]
+[assembly: AssemblyCopyright("Copyright © Anthony Haddox 2016")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+
+[assembly: Guid("12749B9C-17E0-4AF2-93AA-92288633BCAB")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+
+[assembly: AssemblyVersion("0.1.1.*")]
+[assembly: AssemblyFileVersion("0.1.1.0")]
+
diff --git a/Tundra Core/SavingsAccount.cs b/Tundra Core/SavingsAccount.cs
new file mode 100644
index 0000000..9a53f73
--- /dev/null
+++ b/Tundra Core/SavingsAccount.cs
@@ -0,0 +1,18 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated from a template.
+//
+// Manual changes to this file may cause unexpected behavior in your application.
+// Manual changes to this file will be overwritten if the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace TundraCore
+{
+ using System;
+ using System.Collections.Generic;
+
+ public partial class SavingsAccount : Account
+ {
+ }
+}
diff --git a/Tundra Core/Transaction.cs b/Tundra Core/Transaction.cs
new file mode 100644
index 0000000..1d01b44
--- /dev/null
+++ b/Tundra Core/Transaction.cs
@@ -0,0 +1,30 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated from a template.
+//
+// Manual changes to this file may cause unexpected behavior in your application.
+// Manual changes to this file will be overwritten if the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace TundraCore
+{
+ using System;
+ using System.Collections.Generic;
+
+ public abstract partial class Transaction
+ {
+ public int Id { get; set; }
+ public string Name { get; set; }
+ public string Description { get; set; }
+ public decimal Amount { get; set; }
+ public int UserId { get; set; }
+
+ public virtual User User { get; set; }
+
+ public override string ToString()
+ {
+ return Name + " | " + Description + " | $" + Amount;
+ }
+ }
+}
diff --git a/Tundra Core/Tundra Core.csproj b/Tundra Core/Tundra Core.csproj
new file mode 100644
index 0000000..9a58d40
--- /dev/null
+++ b/Tundra Core/Tundra Core.csproj
@@ -0,0 +1,144 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {12749B9C-17E0-4AF2-93AA-92288633BCAB}
+ Library
+ Properties
+ TundraCore
+ TundraCore
+ v4.5.2
+ 512
+
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+ ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll
+ True
+
+
+ ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll
+ True
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ TundraContext.tt
+
+
+ TundraContext.tt
+
+
+ TundraContext.tt
+
+
+ TundraContext.tt
+
+
+ TundraContext.tt
+
+
+
+ TundraContext.tt
+
+
+ TundraContext.tt
+
+
+ True
+ True
+ TundraContext.Context.tt
+
+
+ True
+ True
+ TundraContext.tt
+
+
+ True
+ True
+ TundraContext.edmx
+
+
+ TundraContext.tt
+
+
+
+
+ Designer
+
+
+ Designer
+
+
+ EntityModelCodeGenerator
+ TundraContext.Designer.cs
+
+
+ TundraContext.edmx
+
+
+
+
+
+
+
+ TextTemplatingFileGenerator
+ TundraContext.Context.cs
+ TundraContext.edmx
+
+
+
+ TextTemplatingFileGenerator
+ TundraContext.cs
+ TundraContext.edmx
+
+
+
+
+
\ No newline at end of file
diff --git a/Tundra Core/TundraContext.Context.cs b/Tundra Core/TundraContext.Context.cs
new file mode 100644
index 0000000..6aa8f8a
--- /dev/null
+++ b/Tundra Core/TundraContext.Context.cs
@@ -0,0 +1,33 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated from a template.
+//
+// Manual changes to this file may cause unexpected behavior in your application.
+// Manual changes to this file will be overwritten if the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace TundraCore
+{
+ using System;
+ using System.Data.Entity;
+ using System.Data.Entity.Infrastructure;
+
+ public partial class TundraContext : DbContext
+ {
+ public TundraContext()
+ : base("name=TundraContext")
+ {
+ }
+
+ protected override void OnModelCreating(DbModelBuilder modelBuilder)
+ {
+ throw new UnintentionalCodeFirstException();
+ }
+
+ public virtual DbSet Users { get; set; }
+ public virtual DbSet Accounts { get; set; }
+ public virtual DbSet Goals { get; set; }
+ public virtual DbSet Transactions { get; set; }
+ }
+}
diff --git a/Tundra Core/TundraContext.Context.tt b/Tundra Core/TundraContext.Context.tt
new file mode 100644
index 0000000..56333dc
--- /dev/null
+++ b/Tundra Core/TundraContext.Context.tt
@@ -0,0 +1,636 @@
+<#@ template language="C#" debug="false" hostspecific="true"#>
+<#@ include file="EF6.Utility.CS.ttinclude"#><#@
+ output extension=".cs"#><#
+
+const string inputFile = @"TundraContext.edmx";
+var textTransform = DynamicTextTransformation.Create(this);
+var code = new CodeGenerationTools(this);
+var ef = new MetadataTools(this);
+var typeMapper = new TypeMapper(code, ef, textTransform.Errors);
+var loader = new EdmMetadataLoader(textTransform.Host, textTransform.Errors);
+var itemCollection = loader.CreateEdmItemCollection(inputFile);
+var modelNamespace = loader.GetModelNamespace(inputFile);
+var codeStringGenerator = new CodeStringGenerator(code, typeMapper, ef);
+
+var container = itemCollection.OfType().FirstOrDefault();
+if (container == null)
+{
+ return string.Empty;
+}
+#>
+//------------------------------------------------------------------------------
+//
+// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine1")#>
+//
+// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine2")#>
+// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine3")#>
+//
+//------------------------------------------------------------------------------
+
+<#
+
+var codeNamespace = code.VsNamespaceSuggestion();
+if (!String.IsNullOrEmpty(codeNamespace))
+{
+#>
+namespace <#=code.EscapeNamespace(codeNamespace)#>
+{
+<#
+ PushIndent(" ");
+}
+
+#>
+using System;
+using System.Data.Entity;
+using System.Data.Entity.Infrastructure;
+<#
+if (container.FunctionImports.Any())
+{
+#>
+using System.Data.Entity.Core.Objects;
+using System.Linq;
+<#
+}
+#>
+
+<#=Accessibility.ForType(container)#> partial class <#=code.Escape(container)#> : DbContext
+{
+ public <#=code.Escape(container)#>()
+ : base("name=<#=container.Name#>")
+ {
+<#
+if (!loader.IsLazyLoadingEnabled(container))
+{
+#>
+ this.Configuration.LazyLoadingEnabled = false;
+<#
+}
+
+foreach (var entitySet in container.BaseEntitySets.OfType())
+{
+ // Note: the DbSet members are defined below such that the getter and
+ // setter always have the same accessibility as the DbSet definition
+ if (Accessibility.ForReadOnlyProperty(entitySet) != "public")
+ {
+#>
+ <#=codeStringGenerator.DbSetInitializer(entitySet)#>
+<#
+ }
+}
+#>
+ }
+
+ protected override void OnModelCreating(DbModelBuilder modelBuilder)
+ {
+ throw new UnintentionalCodeFirstException();
+ }
+
+<#
+ foreach (var entitySet in container.BaseEntitySets.OfType())
+ {
+#>
+ <#=codeStringGenerator.DbSet(entitySet)#>
+<#
+ }
+
+ foreach (var edmFunction in container.FunctionImports)
+ {
+ WriteFunctionImport(typeMapper, codeStringGenerator, edmFunction, modelNamespace, includeMergeOption: false);
+ }
+#>
+}
+<#
+
+if (!String.IsNullOrEmpty(codeNamespace))
+{
+ PopIndent();
+#>
+}
+<#
+}
+#>
+<#+
+
+private void WriteFunctionImport(TypeMapper typeMapper, CodeStringGenerator codeStringGenerator, EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
+{
+ if (typeMapper.IsComposable(edmFunction))
+ {
+#>
+
+ [DbFunction("<#=edmFunction.NamespaceName#>", "<#=edmFunction.Name#>")]
+ <#=codeStringGenerator.ComposableFunctionMethod(edmFunction, modelNamespace)#>
+ {
+<#+
+ codeStringGenerator.WriteFunctionParameters(edmFunction, WriteFunctionParameter);
+#>
+ <#=codeStringGenerator.ComposableCreateQuery(edmFunction, modelNamespace)#>
+ }
+<#+
+ }
+ else
+ {
+#>
+
+ <#=codeStringGenerator.FunctionMethod(edmFunction, modelNamespace, includeMergeOption)#>
+ {
+<#+
+ codeStringGenerator.WriteFunctionParameters(edmFunction, WriteFunctionParameter);
+#>
+ <#=codeStringGenerator.ExecuteFunction(edmFunction, modelNamespace, includeMergeOption)#>
+ }
+<#+
+ if (typeMapper.GenerateMergeOptionFunction(edmFunction, includeMergeOption))
+ {
+ WriteFunctionImport(typeMapper, codeStringGenerator, edmFunction, modelNamespace, includeMergeOption: true);
+ }
+ }
+}
+
+public void WriteFunctionParameter(string name, string isNotNull, string notNullInit, string nullInit)
+{
+#>
+ var <#=name#> = <#=isNotNull#> ?
+ <#=notNullInit#> :
+ <#=nullInit#>;
+
+<#+
+}
+
+public const string TemplateId = "CSharp_DbContext_Context_EF6";
+
+public class CodeStringGenerator
+{
+ private readonly CodeGenerationTools _code;
+ private readonly TypeMapper _typeMapper;
+ private readonly MetadataTools _ef;
+
+ public CodeStringGenerator(CodeGenerationTools code, TypeMapper typeMapper, MetadataTools ef)
+ {
+ ArgumentNotNull(code, "code");
+ ArgumentNotNull(typeMapper, "typeMapper");
+ ArgumentNotNull(ef, "ef");
+
+ _code = code;
+ _typeMapper = typeMapper;
+ _ef = ef;
+ }
+
+ public string Property(EdmProperty edmProperty)
+ {
+ return string.Format(
+ CultureInfo.InvariantCulture,
+ "{0} {1} {2} {{ {3}get; {4}set; }}",
+ Accessibility.ForProperty(edmProperty),
+ _typeMapper.GetTypeName(edmProperty.TypeUsage),
+ _code.Escape(edmProperty),
+ _code.SpaceAfter(Accessibility.ForGetter(edmProperty)),
+ _code.SpaceAfter(Accessibility.ForSetter(edmProperty)));
+ }
+
+ public string NavigationProperty(NavigationProperty navProp)
+ {
+ var endType = _typeMapper.GetTypeName(navProp.ToEndMember.GetEntityType());
+ return string.Format(
+ CultureInfo.InvariantCulture,
+ "{0} {1} {2} {{ {3}get; {4}set; }}",
+ AccessibilityAndVirtual(Accessibility.ForNavigationProperty(navProp)),
+ navProp.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many ? ("ICollection<" + endType + ">") : endType,
+ _code.Escape(navProp),
+ _code.SpaceAfter(Accessibility.ForGetter(navProp)),
+ _code.SpaceAfter(Accessibility.ForSetter(navProp)));
+ }
+
+ public string AccessibilityAndVirtual(string accessibility)
+ {
+ return accessibility + (accessibility != "private" ? " virtual" : "");
+ }
+
+ public string EntityClassOpening(EntityType entity)
+ {
+ return string.Format(
+ CultureInfo.InvariantCulture,
+ "{0} {1}partial class {2}{3}",
+ Accessibility.ForType(entity),
+ _code.SpaceAfter(_code.AbstractOption(entity)),
+ _code.Escape(entity),
+ _code.StringBefore(" : ", _typeMapper.GetTypeName(entity.BaseType)));
+ }
+
+ public string EnumOpening(SimpleType enumType)
+ {
+ return string.Format(
+ CultureInfo.InvariantCulture,
+ "{0} enum {1} : {2}",
+ Accessibility.ForType(enumType),
+ _code.Escape(enumType),
+ _code.Escape(_typeMapper.UnderlyingClrType(enumType)));
+ }
+
+ public void WriteFunctionParameters(EdmFunction edmFunction, Action writeParameter)
+ {
+ var parameters = FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
+ foreach (var parameter in parameters.Where(p => p.NeedsLocalVariable))
+ {
+ var isNotNull = parameter.IsNullableOfT ? parameter.FunctionParameterName + ".HasValue" : parameter.FunctionParameterName + " != null";
+ var notNullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", " + parameter.FunctionParameterName + ")";
+ var nullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", typeof(" + TypeMapper.FixNamespaces(parameter.RawClrTypeName) + "))";
+ writeParameter(parameter.LocalVariableName, isNotNull, notNullInit, nullInit);
+ }
+ }
+
+ public string ComposableFunctionMethod(EdmFunction edmFunction, string modelNamespace)
+ {
+ var parameters = _typeMapper.GetParameters(edmFunction);
+
+ return string.Format(
+ CultureInfo.InvariantCulture,
+ "{0} IQueryable<{1}> {2}({3})",
+ AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
+ _typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
+ _code.Escape(edmFunction),
+ string.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray()));
+ }
+
+ public string ComposableCreateQuery(EdmFunction edmFunction, string modelNamespace)
+ {
+ var parameters = _typeMapper.GetParameters(edmFunction);
+
+ return string.Format(
+ CultureInfo.InvariantCulture,
+ "return ((IObjectContextAdapter)this).ObjectContext.CreateQuery<{0}>(\"[{1}].[{2}]({3})\"{4});",
+ _typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
+ edmFunction.NamespaceName,
+ edmFunction.Name,
+ string.Join(", ", parameters.Select(p => "@" + p.EsqlParameterName).ToArray()),
+ _code.StringBefore(", ", string.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray())));
+ }
+
+ public string FunctionMethod(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
+ {
+ var parameters = _typeMapper.GetParameters(edmFunction);
+ var returnType = _typeMapper.GetReturnType(edmFunction);
+
+ var paramList = String.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray());
+ if (includeMergeOption)
+ {
+ paramList = _code.StringAfter(paramList, ", ") + "MergeOption mergeOption";
+ }
+
+ return string.Format(
+ CultureInfo.InvariantCulture,
+ "{0} {1} {2}({3})",
+ AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
+ returnType == null ? "int" : "ObjectResult<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
+ _code.Escape(edmFunction),
+ paramList);
+ }
+
+ public string ExecuteFunction(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
+ {
+ var parameters = _typeMapper.GetParameters(edmFunction);
+ var returnType = _typeMapper.GetReturnType(edmFunction);
+
+ var callParams = _code.StringBefore(", ", String.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray()));
+ if (includeMergeOption)
+ {
+ callParams = ", mergeOption" + callParams;
+ }
+
+ return string.Format(
+ CultureInfo.InvariantCulture,
+ "return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction{0}(\"{1}\"{2});",
+ returnType == null ? "" : "<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
+ edmFunction.Name,
+ callParams);
+ }
+
+ public string DbSet(EntitySet entitySet)
+ {
+ return string.Format(
+ CultureInfo.InvariantCulture,
+ "{0} virtual DbSet<{1}> {2} {{ get; set; }}",
+ Accessibility.ForReadOnlyProperty(entitySet),
+ _typeMapper.GetTypeName(entitySet.ElementType),
+ _code.Escape(entitySet));
+ }
+
+ public string DbSetInitializer(EntitySet entitySet)
+ {
+ return string.Format(
+ CultureInfo.InvariantCulture,
+ "{0} = Set<{1}>();",
+ _code.Escape(entitySet),
+ _typeMapper.GetTypeName(entitySet.ElementType));
+ }
+
+ public string UsingDirectives(bool inHeader, bool includeCollections = true)
+ {
+ return inHeader == string.IsNullOrEmpty(_code.VsNamespaceSuggestion())
+ ? string.Format(
+ CultureInfo.InvariantCulture,
+ "{0}using System;{1}" +
+ "{2}",
+ inHeader ? Environment.NewLine : "",
+ includeCollections ? (Environment.NewLine + "using System.Collections.Generic;") : "",
+ inHeader ? "" : Environment.NewLine)
+ : "";
+ }
+}
+
+public class TypeMapper
+{
+ private const string ExternalTypeNameAttributeName = @"http://schemas.microsoft.com/ado/2006/04/codegeneration:ExternalTypeName";
+
+ private readonly System.Collections.IList _errors;
+ private readonly CodeGenerationTools _code;
+ private readonly MetadataTools _ef;
+
+ public static string FixNamespaces(string typeName)
+ {
+ return typeName.Replace("System.Data.Spatial.", "System.Data.Entity.Spatial.");
+ }
+
+ public TypeMapper(CodeGenerationTools code, MetadataTools ef, System.Collections.IList errors)
+ {
+ ArgumentNotNull(code, "code");
+ ArgumentNotNull(ef, "ef");
+ ArgumentNotNull(errors, "errors");
+
+ _code = code;
+ _ef = ef;
+ _errors = errors;
+ }
+
+ public string GetTypeName(TypeUsage typeUsage)
+ {
+ return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace: null);
+ }
+
+ public string GetTypeName(EdmType edmType)
+ {
+ return GetTypeName(edmType, isNullable: null, modelNamespace: null);
+ }
+
+ public string GetTypeName(TypeUsage typeUsage, string modelNamespace)
+ {
+ return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace);
+ }
+
+ public string GetTypeName(EdmType edmType, string modelNamespace)
+ {
+ return GetTypeName(edmType, isNullable: null, modelNamespace: modelNamespace);
+ }
+
+ public string GetTypeName(EdmType edmType, bool? isNullable, string modelNamespace)
+ {
+ if (edmType == null)
+ {
+ return null;
+ }
+
+ var collectionType = edmType as CollectionType;
+ if (collectionType != null)
+ {
+ return String.Format(CultureInfo.InvariantCulture, "ICollection<{0}>", GetTypeName(collectionType.TypeUsage, modelNamespace));
+ }
+
+ var typeName = _code.Escape(edmType.MetadataProperties
+ .Where(p => p.Name == ExternalTypeNameAttributeName)
+ .Select(p => (string)p.Value)
+ .FirstOrDefault())
+ ?? (modelNamespace != null && edmType.NamespaceName != modelNamespace ?
+ _code.CreateFullName(_code.EscapeNamespace(edmType.NamespaceName), _code.Escape(edmType)) :
+ _code.Escape(edmType));
+
+ if (edmType is StructuralType)
+ {
+ return typeName;
+ }
+
+ if (edmType is SimpleType)
+ {
+ var clrType = UnderlyingClrType(edmType);
+ if (!IsEnumType(edmType))
+ {
+ typeName = _code.Escape(clrType);
+ }
+
+ typeName = FixNamespaces(typeName);
+
+ return clrType.IsValueType && isNullable == true ?
+ String.Format(CultureInfo.InvariantCulture, "Nullable<{0}>", typeName) :
+ typeName;
+ }
+
+ throw new ArgumentException("edmType");
+ }
+
+ public Type UnderlyingClrType(EdmType edmType)
+ {
+ ArgumentNotNull(edmType, "edmType");
+
+ var primitiveType = edmType as PrimitiveType;
+ if (primitiveType != null)
+ {
+ return primitiveType.ClrEquivalentType;
+ }
+
+ if (IsEnumType(edmType))
+ {
+ return GetEnumUnderlyingType(edmType).ClrEquivalentType;
+ }
+
+ return typeof(object);
+ }
+
+ public object GetEnumMemberValue(MetadataItem enumMember)
+ {
+ ArgumentNotNull(enumMember, "enumMember");
+
+ var valueProperty = enumMember.GetType().GetProperty("Value");
+ return valueProperty == null ? null : valueProperty.GetValue(enumMember, null);
+ }
+
+ public string GetEnumMemberName(MetadataItem enumMember)
+ {
+ ArgumentNotNull(enumMember, "enumMember");
+
+ var nameProperty = enumMember.GetType().GetProperty("Name");
+ return nameProperty == null ? null : (string)nameProperty.GetValue(enumMember, null);
+ }
+
+ public System.Collections.IEnumerable GetEnumMembers(EdmType enumType)
+ {
+ ArgumentNotNull(enumType, "enumType");
+
+ var membersProperty = enumType.GetType().GetProperty("Members");
+ return membersProperty != null
+ ? (System.Collections.IEnumerable)membersProperty.GetValue(enumType, null)
+ : Enumerable.Empty();
+ }
+
+ public bool EnumIsFlags(EdmType enumType)
+ {
+ ArgumentNotNull(enumType, "enumType");
+
+ var isFlagsProperty = enumType.GetType().GetProperty("IsFlags");
+ return isFlagsProperty != null && (bool)isFlagsProperty.GetValue(enumType, null);
+ }
+
+ public bool IsEnumType(GlobalItem edmType)
+ {
+ ArgumentNotNull(edmType, "edmType");
+
+ return edmType.GetType().Name == "EnumType";
+ }
+
+ public PrimitiveType GetEnumUnderlyingType(EdmType enumType)
+ {
+ ArgumentNotNull(enumType, "enumType");
+
+ return (PrimitiveType)enumType.GetType().GetProperty("UnderlyingType").GetValue(enumType, null);
+ }
+
+ public string CreateLiteral(object value)
+ {
+ if (value == null || value.GetType() != typeof(TimeSpan))
+ {
+ return _code.CreateLiteral(value);
+ }
+
+ return string.Format(CultureInfo.InvariantCulture, "new TimeSpan({0})", ((TimeSpan)value).Ticks);
+ }
+
+ public bool VerifyCaseInsensitiveTypeUniqueness(IEnumerable types, string sourceFile)
+ {
+ ArgumentNotNull(types, "types");
+ ArgumentNotNull(sourceFile, "sourceFile");
+
+ var hash = new HashSet(StringComparer.InvariantCultureIgnoreCase);
+ if (types.Any(item => !hash.Add(item)))
+ {
+ _errors.Add(
+ new CompilerError(sourceFile, -1, -1, "6023",
+ String.Format(CultureInfo.CurrentCulture, CodeGenerationTools.GetResourceString("Template_CaseInsensitiveTypeConflict"))));
+ return false;
+ }
+ return true;
+ }
+
+ public IEnumerable GetEnumItemsToGenerate(IEnumerable itemCollection)
+ {
+ return GetItemsToGenerate(itemCollection)
+ .Where(e => IsEnumType(e));
+ }
+
+ public IEnumerable GetItemsToGenerate(IEnumerable itemCollection) where T: EdmType
+ {
+ return itemCollection
+ .OfType()
+ .Where(i => !i.MetadataProperties.Any(p => p.Name == ExternalTypeNameAttributeName))
+ .OrderBy(i => i.Name);
+ }
+
+ public IEnumerable GetAllGlobalItems(IEnumerable itemCollection)
+ {
+ return itemCollection
+ .Where(i => i is EntityType || i is ComplexType || i is EntityContainer || IsEnumType(i))
+ .Select(g => GetGlobalItemName(g));
+ }
+
+ public string GetGlobalItemName(GlobalItem item)
+ {
+ if (item is EdmType)
+ {
+ return ((EdmType)item).Name;
+ }
+ else
+ {
+ return ((EntityContainer)item).Name;
+ }
+ }
+
+ public IEnumerable GetSimpleProperties(EntityType type)
+ {
+ return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
+ }
+
+ public IEnumerable GetSimpleProperties(ComplexType type)
+ {
+ return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
+ }
+
+ public IEnumerable GetComplexProperties(EntityType type)
+ {
+ return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
+ }
+
+ public IEnumerable GetComplexProperties(ComplexType type)
+ {
+ return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
+ }
+
+ public IEnumerable GetPropertiesWithDefaultValues(EntityType type)
+ {
+ return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
+ }
+
+ public IEnumerable GetPropertiesWithDefaultValues(ComplexType type)
+ {
+ return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
+ }
+
+ public IEnumerable GetNavigationProperties(EntityType type)
+ {
+ return type.NavigationProperties.Where(np => np.DeclaringType == type);
+ }
+
+ public IEnumerable GetCollectionNavigationProperties(EntityType type)
+ {
+ return type.NavigationProperties.Where(np => np.DeclaringType == type && np.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many);
+ }
+
+ public FunctionParameter GetReturnParameter(EdmFunction edmFunction)
+ {
+ ArgumentNotNull(edmFunction, "edmFunction");
+
+ var returnParamsProperty = edmFunction.GetType().GetProperty("ReturnParameters");
+ return returnParamsProperty == null
+ ? edmFunction.ReturnParameter
+ : ((IEnumerable)returnParamsProperty.GetValue(edmFunction, null)).FirstOrDefault();
+ }
+
+ public bool IsComposable(EdmFunction edmFunction)
+ {
+ ArgumentNotNull(edmFunction, "edmFunction");
+
+ var isComposableProperty = edmFunction.GetType().GetProperty("IsComposableAttribute");
+ return isComposableProperty != null && (bool)isComposableProperty.GetValue(edmFunction, null);
+ }
+
+ public IEnumerable GetParameters(EdmFunction edmFunction)
+ {
+ return FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
+ }
+
+ public TypeUsage GetReturnType(EdmFunction edmFunction)
+ {
+ var returnParam = GetReturnParameter(edmFunction);
+ return returnParam == null ? null : _ef.GetElementType(returnParam.TypeUsage);
+ }
+
+ public bool GenerateMergeOptionFunction(EdmFunction edmFunction, bool includeMergeOption)
+ {
+ var returnType = GetReturnType(edmFunction);
+ return !includeMergeOption && returnType != null && returnType.EdmType.BuiltInTypeKind == BuiltInTypeKind.EntityType;
+ }
+}
+
+public static void ArgumentNotNull(T arg, string name) where T : class
+{
+ if (arg == null)
+ {
+ throw new ArgumentNullException(name);
+ }
+}
+#>
\ No newline at end of file
diff --git a/Tundra Core/TundraContext.Designer.cs b/Tundra Core/TundraContext.Designer.cs
new file mode 100644
index 0000000..2f2957c
--- /dev/null
+++ b/Tundra Core/TundraContext.Designer.cs
@@ -0,0 +1,10 @@
+// T4 code generation is enabled for model 'C:\Users\antzy_000\RiderProjects\Tundra\Tundra Core\TundraContext.edmx'.
+// To enable legacy code generation, change the value of the 'Code Generation Strategy' designer
+// property to 'Legacy ObjectContext'. This property is available in the Properties Window when the model
+// is open in the designer.
+
+// If no context and entity classes have been generated, it may be because you created an empty model but
+// have not yet chosen which version of Entity Framework to use. To generate a context class and entity
+// classes for your model, open the model in the designer, right-click on the designer surface, and
+// select 'Update Model from Database...', 'Generate Database from Model...', or 'Add Code Generation
+// Item...'.
\ No newline at end of file
diff --git a/Tundra Core/TundraContext.cs b/Tundra Core/TundraContext.cs
new file mode 100644
index 0000000..7cc0662
--- /dev/null
+++ b/Tundra Core/TundraContext.cs
@@ -0,0 +1,9 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated from a template.
+//
+// Manual changes to this file may cause unexpected behavior in your application.
+// Manual changes to this file will be overwritten if the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
diff --git a/Tundra Core/TundraContext.edmx b/Tundra Core/TundraContext.edmx
new file mode 100644
index 0000000..858e8ce
--- /dev/null
+++ b/Tundra Core/TundraContext.edmx
@@ -0,0 +1,415 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Tundra Core/TundraContext.edmx.diagram b/Tundra Core/TundraContext.edmx.diagram
new file mode 100644
index 0000000..b29526f
--- /dev/null
+++ b/Tundra Core/TundraContext.edmx.diagram
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Tundra Core/TundraContext.edmx.sql b/Tundra Core/TundraContext.edmx.sql
new file mode 100644
index 0000000..8e5daab
--- /dev/null
+++ b/Tundra Core/TundraContext.edmx.sql
@@ -0,0 +1,237 @@
+
+-- --------------------------------------------------
+-- Entity Designer DDL Script for SQL Server 2005, 2008, 2012 and Azure
+-- --------------------------------------------------
+-- Date Created: 08/26/2016 15:01:46
+-- Generated from EDMX file: C:\Users\antzy_000\RiderProjects\Tundra\Tundra Core\TundraContext.edmx
+-- --------------------------------------------------
+
+SET QUOTED_IDENTIFIER OFF;
+GO
+USE [TundraCore];
+GO
+IF SCHEMA_ID(N'TundraCore') IS NULL EXECUTE(N'CREATE SCHEMA [TundraCore]');
+GO
+
+-- --------------------------------------------------
+-- Dropping existing FOREIGN KEY constraints
+-- --------------------------------------------------
+
+
+-- --------------------------------------------------
+-- Dropping existing tables
+-- --------------------------------------------------
+
+
+-- --------------------------------------------------
+-- Creating all tables
+-- --------------------------------------------------
+
+-- Creating table 'Users'
+CREATE TABLE [TundraCore].[Users] (
+ [Id] int IDENTITY(1,1) NOT NULL,
+ [Name] nvarchar(max) NOT NULL,
+ [Password] nvarchar(max) NOT NULL,
+ [RequiresValidation] bit NOT NULL
+);
+GO
+
+-- Creating table 'Accounts'
+CREATE TABLE [TundraCore].[Accounts] (
+ [Id] int IDENTITY(1,1) NOT NULL,
+ [Name] nvarchar(max) NOT NULL,
+ [Balance] decimal(18,2) NOT NULL,
+ [UserId] int NOT NULL
+);
+GO
+
+-- Creating table 'Goals'
+CREATE TABLE [TundraCore].[Goals] (
+ [Id] int IDENTITY(1,1) NOT NULL,
+ [Name] nvarchar(max) NOT NULL,
+ [Description] nvarchar(max) NOT NULL,
+ [TargetAmount] decimal(18,2) NOT NULL,
+ [AcruedAmount] decimal(18,2) NOT NULL,
+ [ContributionAmount] decimal(18,2) NOT NULL,
+ [Accomplished] bit NOT NULL,
+ [Created] datetime NOT NULL,
+ [Deadline] datetime NOT NULL,
+ [Modified] datetime NOT NULL,
+ [UserId] int NOT NULL
+);
+GO
+
+-- Creating table 'Transactions'
+CREATE TABLE [TundraCore].[Transactions] (
+ [Id] int IDENTITY(1,1) NOT NULL,
+ [Name] nvarchar(max) NOT NULL,
+ [Description] nvarchar(max) NOT NULL,
+ [Amount] decimal(18,2) NOT NULL,
+ [UserId] int NOT NULL
+);
+GO
+
+-- Creating table 'Accounts_SavingsAccount'
+CREATE TABLE [TundraCore].[Accounts_SavingsAccount] (
+ [Id] int NOT NULL
+);
+GO
+
+-- Creating table 'Accounts_CheckingAccount'
+CREATE TABLE [TundraCore].[Accounts_CheckingAccount] (
+ [Id] int NOT NULL
+);
+GO
+
+-- Creating table 'Transactions_Income'
+CREATE TABLE [TundraCore].[Transactions_Income] (
+ [Id] int NOT NULL
+);
+GO
+
+-- Creating table 'Transactions_Expense'
+CREATE TABLE [TundraCore].[Transactions_Expense] (
+ [Id] int NOT NULL
+);
+GO
+
+-- --------------------------------------------------
+-- Creating all PRIMARY KEY constraints
+-- --------------------------------------------------
+
+-- Creating primary key on [Id] in table 'Users'
+ALTER TABLE [TundraCore].[Users]
+ADD CONSTRAINT [PK_Users]
+ PRIMARY KEY CLUSTERED ([Id] ASC);
+GO
+
+-- Creating primary key on [Id] in table 'Accounts'
+ALTER TABLE [TundraCore].[Accounts]
+ADD CONSTRAINT [PK_Accounts]
+ PRIMARY KEY CLUSTERED ([Id] ASC);
+GO
+
+-- Creating primary key on [Id] in table 'Goals'
+ALTER TABLE [TundraCore].[Goals]
+ADD CONSTRAINT [PK_Goals]
+ PRIMARY KEY CLUSTERED ([Id] ASC);
+GO
+
+-- Creating primary key on [Id] in table 'Transactions'
+ALTER TABLE [TundraCore].[Transactions]
+ADD CONSTRAINT [PK_Transactions]
+ PRIMARY KEY CLUSTERED ([Id] ASC);
+GO
+
+-- Creating primary key on [Id] in table 'Accounts_SavingsAccount'
+ALTER TABLE [TundraCore].[Accounts_SavingsAccount]
+ADD CONSTRAINT [PK_Accounts_SavingsAccount]
+ PRIMARY KEY CLUSTERED ([Id] ASC);
+GO
+
+-- Creating primary key on [Id] in table 'Accounts_CheckingAccount'
+ALTER TABLE [TundraCore].[Accounts_CheckingAccount]
+ADD CONSTRAINT [PK_Accounts_CheckingAccount]
+ PRIMARY KEY CLUSTERED ([Id] ASC);
+GO
+
+-- Creating primary key on [Id] in table 'Transactions_Income'
+ALTER TABLE [TundraCore].[Transactions_Income]
+ADD CONSTRAINT [PK_Transactions_Income]
+ PRIMARY KEY CLUSTERED ([Id] ASC);
+GO
+
+-- Creating primary key on [Id] in table 'Transactions_Expense'
+ALTER TABLE [TundraCore].[Transactions_Expense]
+ADD CONSTRAINT [PK_Transactions_Expense]
+ PRIMARY KEY CLUSTERED ([Id] ASC);
+GO
+
+-- --------------------------------------------------
+-- Creating all FOREIGN KEY constraints
+-- --------------------------------------------------
+
+-- Creating foreign key on [UserId] in table 'Accounts'
+ALTER TABLE [TundraCore].[Accounts]
+ADD CONSTRAINT [FK_UserAccount]
+ FOREIGN KEY ([UserId])
+ REFERENCES [TundraCore].[Users]
+ ([Id])
+ ON DELETE NO ACTION ON UPDATE NO ACTION;
+GO
+
+-- Creating non-clustered index for FOREIGN KEY 'FK_UserAccount'
+CREATE INDEX [IX_FK_UserAccount]
+ON [TundraCore].[Accounts]
+ ([UserId]);
+GO
+
+-- Creating foreign key on [UserId] in table 'Goals'
+ALTER TABLE [TundraCore].[Goals]
+ADD CONSTRAINT [FK_UserGoal]
+ FOREIGN KEY ([UserId])
+ REFERENCES [TundraCore].[Users]
+ ([Id])
+ ON DELETE NO ACTION ON UPDATE NO ACTION;
+GO
+
+-- Creating non-clustered index for FOREIGN KEY 'FK_UserGoal'
+CREATE INDEX [IX_FK_UserGoal]
+ON [TundraCore].[Goals]
+ ([UserId]);
+GO
+
+-- Creating foreign key on [UserId] in table 'Transactions'
+ALTER TABLE [TundraCore].[Transactions]
+ADD CONSTRAINT [FK_UserTransaction]
+ FOREIGN KEY ([UserId])
+ REFERENCES [TundraCore].[Users]
+ ([Id])
+ ON DELETE NO ACTION ON UPDATE NO ACTION;
+GO
+
+-- Creating non-clustered index for FOREIGN KEY 'FK_UserTransaction'
+CREATE INDEX [IX_FK_UserTransaction]
+ON [TundraCore].[Transactions]
+ ([UserId]);
+GO
+
+-- Creating foreign key on [Id] in table 'Accounts_SavingsAccount'
+ALTER TABLE [TundraCore].[Accounts_SavingsAccount]
+ADD CONSTRAINT [FK_SavingsAccount_inherits_Account]
+ FOREIGN KEY ([Id])
+ REFERENCES [TundraCore].[Accounts]
+ ([Id])
+ ON DELETE CASCADE ON UPDATE NO ACTION;
+GO
+
+-- Creating foreign key on [Id] in table 'Accounts_CheckingAccount'
+ALTER TABLE [TundraCore].[Accounts_CheckingAccount]
+ADD CONSTRAINT [FK_CheckingAccount_inherits_Account]
+ FOREIGN KEY ([Id])
+ REFERENCES [TundraCore].[Accounts]
+ ([Id])
+ ON DELETE CASCADE ON UPDATE NO ACTION;
+GO
+
+-- Creating foreign key on [Id] in table 'Transactions_Income'
+ALTER TABLE [TundraCore].[Transactions_Income]
+ADD CONSTRAINT [FK_Income_inherits_Transaction]
+ FOREIGN KEY ([Id])
+ REFERENCES [TundraCore].[Transactions]
+ ([Id])
+ ON DELETE CASCADE ON UPDATE NO ACTION;
+GO
+
+-- Creating foreign key on [Id] in table 'Transactions_Expense'
+ALTER TABLE [TundraCore].[Transactions_Expense]
+ADD CONSTRAINT [FK_Expense_inherits_Transaction]
+ FOREIGN KEY ([Id])
+ REFERENCES [TundraCore].[Transactions]
+ ([Id])
+ ON DELETE CASCADE ON UPDATE NO ACTION;
+GO
+
+-- --------------------------------------------------
+-- Script has ended
+-- --------------------------------------------------
\ No newline at end of file
diff --git a/Tundra Core/TundraContext.tt b/Tundra Core/TundraContext.tt
new file mode 100644
index 0000000..6f49f26
--- /dev/null
+++ b/Tundra Core/TundraContext.tt
@@ -0,0 +1,733 @@
+<#@ template language="C#" debug="false" hostspecific="true"#>
+<#@ include file="EF6.Utility.CS.ttinclude"#><#@
+ output extension=".cs"#><#
+
+const string inputFile = @"TundraContext.edmx";
+var textTransform = DynamicTextTransformation.Create(this);
+var code = new CodeGenerationTools(this);
+var ef = new MetadataTools(this);
+var typeMapper = new TypeMapper(code, ef, textTransform.Errors);
+var fileManager = EntityFrameworkTemplateFileManager.Create(this);
+var itemCollection = new EdmMetadataLoader(textTransform.Host, textTransform.Errors).CreateEdmItemCollection(inputFile);
+var codeStringGenerator = new CodeStringGenerator(code, typeMapper, ef);
+
+if (!typeMapper.VerifyCaseInsensitiveTypeUniqueness(typeMapper.GetAllGlobalItems(itemCollection), inputFile))
+{
+ return string.Empty;
+}
+
+WriteHeader(codeStringGenerator, fileManager);
+
+foreach (var entity in typeMapper.GetItemsToGenerate(itemCollection))
+{
+ fileManager.StartNewFile(entity.Name + ".cs");
+ BeginNamespace(code);
+#>
+<#=codeStringGenerator.UsingDirectives(inHeader: false)#>
+<#=codeStringGenerator.EntityClassOpening(entity)#>
+{
+<#
+ var propertiesWithDefaultValues = typeMapper.GetPropertiesWithDefaultValues(entity);
+ var collectionNavigationProperties = typeMapper.GetCollectionNavigationProperties(entity);
+ var complexProperties = typeMapper.GetComplexProperties(entity);
+
+ if (propertiesWithDefaultValues.Any() || collectionNavigationProperties.Any() || complexProperties.Any())
+ {
+#>
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
+ public <#=code.Escape(entity)#>()
+ {
+<#
+ foreach (var edmProperty in propertiesWithDefaultValues)
+ {
+#>
+ this.<#=code.Escape(edmProperty)#> = <#=typeMapper.CreateLiteral(edmProperty.DefaultValue)#>;
+<#
+ }
+
+ foreach (var navigationProperty in collectionNavigationProperties)
+ {
+#>
+ this.<#=code.Escape(navigationProperty)#> = new HashSet<<#=typeMapper.GetTypeName(navigationProperty.ToEndMember.GetEntityType())#>>();
+<#
+ }
+
+ foreach (var complexProperty in complexProperties)
+ {
+#>
+ this.<#=code.Escape(complexProperty)#> = new <#=typeMapper.GetTypeName(complexProperty.TypeUsage)#>();
+<#
+ }
+#>
+ }
+
+<#
+ }
+
+ var simpleProperties = typeMapper.GetSimpleProperties(entity);
+ if (simpleProperties.Any())
+ {
+ foreach (var edmProperty in simpleProperties)
+ {
+#>
+ <#=codeStringGenerator.Property(edmProperty)#>
+<#
+ }
+ }
+
+ if (complexProperties.Any())
+ {
+#>
+
+<#
+ foreach(var complexProperty in complexProperties)
+ {
+#>
+ <#=codeStringGenerator.Property(complexProperty)#>
+<#
+ }
+ }
+
+ var navigationProperties = typeMapper.GetNavigationProperties(entity);
+ if (navigationProperties.Any())
+ {
+#>
+
+<#
+ foreach (var navigationProperty in navigationProperties)
+ {
+ if (navigationProperty.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many)
+ {
+#>
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+<#
+ }
+#>
+ <#=codeStringGenerator.NavigationProperty(navigationProperty)#>
+<#
+ }
+ }
+#>
+}
+<#
+ EndNamespace(code);
+}
+
+foreach (var complex in typeMapper.GetItemsToGenerate(itemCollection))
+{
+ fileManager.StartNewFile(complex.Name + ".cs");
+ BeginNamespace(code);
+#>
+<#=codeStringGenerator.UsingDirectives(inHeader: false, includeCollections: false)#>
+<#=Accessibility.ForType(complex)#> partial class <#=code.Escape(complex)#>
+{
+<#
+ var complexProperties = typeMapper.GetComplexProperties(complex);
+ var propertiesWithDefaultValues = typeMapper.GetPropertiesWithDefaultValues(complex);
+
+ if (propertiesWithDefaultValues.Any() || complexProperties.Any())
+ {
+#>
+ public <#=code.Escape(complex)#>()
+ {
+<#
+ foreach (var edmProperty in propertiesWithDefaultValues)
+ {
+#>
+ this.<#=code.Escape(edmProperty)#> = <#=typeMapper.CreateLiteral(edmProperty.DefaultValue)#>;
+<#
+ }
+
+ foreach (var complexProperty in complexProperties)
+ {
+#>
+ this.<#=code.Escape(complexProperty)#> = new <#=typeMapper.GetTypeName(complexProperty.TypeUsage)#>();
+<#
+ }
+#>
+ }
+
+<#
+ }
+
+ var simpleProperties = typeMapper.GetSimpleProperties(complex);
+ if (simpleProperties.Any())
+ {
+ foreach(var edmProperty in simpleProperties)
+ {
+#>
+ <#=codeStringGenerator.Property(edmProperty)#>
+<#
+ }
+ }
+
+ if (complexProperties.Any())
+ {
+#>
+
+<#
+ foreach(var edmProperty in complexProperties)
+ {
+#>
+ <#=codeStringGenerator.Property(edmProperty)#>
+<#
+ }
+ }
+#>
+}
+<#
+ EndNamespace(code);
+}
+
+foreach (var enumType in typeMapper.GetEnumItemsToGenerate(itemCollection))
+{
+ fileManager.StartNewFile(enumType.Name + ".cs");
+ BeginNamespace(code);
+#>
+<#=codeStringGenerator.UsingDirectives(inHeader: false, includeCollections: false)#>
+<#
+ if (typeMapper.EnumIsFlags(enumType))
+ {
+#>
+[Flags]
+<#
+ }
+#>
+<#=codeStringGenerator.EnumOpening(enumType)#>
+{
+<#
+ var foundOne = false;
+
+ foreach (MetadataItem member in typeMapper.GetEnumMembers(enumType))
+ {
+ foundOne = true;
+#>
+ <#=code.Escape(typeMapper.GetEnumMemberName(member))#> = <#=typeMapper.GetEnumMemberValue(member)#>,
+<#
+ }
+
+ if (foundOne)
+ {
+ this.GenerationEnvironment.Remove(this.GenerationEnvironment.Length - 3, 1);
+ }
+#>
+}
+<#
+ EndNamespace(code);
+}
+
+fileManager.Process();
+
+#>
+<#+
+
+public void WriteHeader(CodeStringGenerator codeStringGenerator, EntityFrameworkTemplateFileManager fileManager)
+{
+ fileManager.StartHeader();
+#>
+//------------------------------------------------------------------------------
+//
+// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine1")#>
+//
+// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine2")#>
+// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine3")#>
+//
+//------------------------------------------------------------------------------
+<#=codeStringGenerator.UsingDirectives(inHeader: true)#>
+<#+
+ fileManager.EndBlock();
+}
+
+public void BeginNamespace(CodeGenerationTools code)
+{
+ var codeNamespace = code.VsNamespaceSuggestion();
+ if (!String.IsNullOrEmpty(codeNamespace))
+ {
+#>
+namespace <#=code.EscapeNamespace(codeNamespace)#>
+{
+<#+
+ PushIndent(" ");
+ }
+}
+
+public void EndNamespace(CodeGenerationTools code)
+{
+ if (!String.IsNullOrEmpty(code.VsNamespaceSuggestion()))
+ {
+ PopIndent();
+#>
+}
+<#+
+ }
+}
+
+public const string TemplateId = "CSharp_DbContext_Types_EF6";
+
+public class CodeStringGenerator
+{
+ private readonly CodeGenerationTools _code;
+ private readonly TypeMapper _typeMapper;
+ private readonly MetadataTools _ef;
+
+ public CodeStringGenerator(CodeGenerationTools code, TypeMapper typeMapper, MetadataTools ef)
+ {
+ ArgumentNotNull(code, "code");
+ ArgumentNotNull(typeMapper, "typeMapper");
+ ArgumentNotNull(ef, "ef");
+
+ _code = code;
+ _typeMapper = typeMapper;
+ _ef = ef;
+ }
+
+ public string Property(EdmProperty edmProperty)
+ {
+ return string.Format(
+ CultureInfo.InvariantCulture,
+ "{0} {1} {2} {{ {3}get; {4}set; }}",
+ Accessibility.ForProperty(edmProperty),
+ _typeMapper.GetTypeName(edmProperty.TypeUsage),
+ _code.Escape(edmProperty),
+ _code.SpaceAfter(Accessibility.ForGetter(edmProperty)),
+ _code.SpaceAfter(Accessibility.ForSetter(edmProperty)));
+ }
+
+ public string NavigationProperty(NavigationProperty navProp)
+ {
+ var endType = _typeMapper.GetTypeName(navProp.ToEndMember.GetEntityType());
+ return string.Format(
+ CultureInfo.InvariantCulture,
+ "{0} {1} {2} {{ {3}get; {4}set; }}",
+ AccessibilityAndVirtual(Accessibility.ForNavigationProperty(navProp)),
+ navProp.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many ? ("ICollection<" + endType + ">") : endType,
+ _code.Escape(navProp),
+ _code.SpaceAfter(Accessibility.ForGetter(navProp)),
+ _code.SpaceAfter(Accessibility.ForSetter(navProp)));
+ }
+
+ public string AccessibilityAndVirtual(string accessibility)
+ {
+ return accessibility + (accessibility != "private" ? " virtual" : "");
+ }
+
+ public string EntityClassOpening(EntityType entity)
+ {
+ return string.Format(
+ CultureInfo.InvariantCulture,
+ "{0} {1}partial class {2}{3}",
+ Accessibility.ForType(entity),
+ _code.SpaceAfter(_code.AbstractOption(entity)),
+ _code.Escape(entity),
+ _code.StringBefore(" : ", _typeMapper.GetTypeName(entity.BaseType)));
+ }
+
+ public string EnumOpening(SimpleType enumType)
+ {
+ return string.Format(
+ CultureInfo.InvariantCulture,
+ "{0} enum {1} : {2}",
+ Accessibility.ForType(enumType),
+ _code.Escape(enumType),
+ _code.Escape(_typeMapper.UnderlyingClrType(enumType)));
+ }
+
+ public void WriteFunctionParameters(EdmFunction edmFunction, Action writeParameter)
+ {
+ var parameters = FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
+ foreach (var parameter in parameters.Where(p => p.NeedsLocalVariable))
+ {
+ var isNotNull = parameter.IsNullableOfT ? parameter.FunctionParameterName + ".HasValue" : parameter.FunctionParameterName + " != null";
+ var notNullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", " + parameter.FunctionParameterName + ")";
+ var nullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", typeof(" + TypeMapper.FixNamespaces(parameter.RawClrTypeName) + "))";
+ writeParameter(parameter.LocalVariableName, isNotNull, notNullInit, nullInit);
+ }
+ }
+
+ public string ComposableFunctionMethod(EdmFunction edmFunction, string modelNamespace)
+ {
+ var parameters = _typeMapper.GetParameters(edmFunction);
+
+ return string.Format(
+ CultureInfo.InvariantCulture,
+ "{0} IQueryable<{1}> {2}({3})",
+ AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
+ _typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
+ _code.Escape(edmFunction),
+ string.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray()));
+ }
+
+ public string ComposableCreateQuery(EdmFunction edmFunction, string modelNamespace)
+ {
+ var parameters = _typeMapper.GetParameters(edmFunction);
+
+ return string.Format(
+ CultureInfo.InvariantCulture,
+ "return ((IObjectContextAdapter)this).ObjectContext.CreateQuery<{0}>(\"[{1}].[{2}]({3})\"{4});",
+ _typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
+ edmFunction.NamespaceName,
+ edmFunction.Name,
+ string.Join(", ", parameters.Select(p => "@" + p.EsqlParameterName).ToArray()),
+ _code.StringBefore(", ", string.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray())));
+ }
+
+ public string FunctionMethod(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
+ {
+ var parameters = _typeMapper.GetParameters(edmFunction);
+ var returnType = _typeMapper.GetReturnType(edmFunction);
+
+ var paramList = String.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray());
+ if (includeMergeOption)
+ {
+ paramList = _code.StringAfter(paramList, ", ") + "MergeOption mergeOption";
+ }
+
+ return string.Format(
+ CultureInfo.InvariantCulture,
+ "{0} {1} {2}({3})",
+ AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
+ returnType == null ? "int" : "ObjectResult<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
+ _code.Escape(edmFunction),
+ paramList);
+ }
+
+ public string ExecuteFunction(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
+ {
+ var parameters = _typeMapper.GetParameters(edmFunction);
+ var returnType = _typeMapper.GetReturnType(edmFunction);
+
+ var callParams = _code.StringBefore(", ", String.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray()));
+ if (includeMergeOption)
+ {
+ callParams = ", mergeOption" + callParams;
+ }
+
+ return string.Format(
+ CultureInfo.InvariantCulture,
+ "return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction{0}(\"{1}\"{2});",
+ returnType == null ? "" : "<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
+ edmFunction.Name,
+ callParams);
+ }
+
+ public string DbSet(EntitySet entitySet)
+ {
+ return string.Format(
+ CultureInfo.InvariantCulture,
+ "{0} virtual DbSet<{1}> {2} {{ get; set; }}",
+ Accessibility.ForReadOnlyProperty(entitySet),
+ _typeMapper.GetTypeName(entitySet.ElementType),
+ _code.Escape(entitySet));
+ }
+
+ public string UsingDirectives(bool inHeader, bool includeCollections = true)
+ {
+ return inHeader == string.IsNullOrEmpty(_code.VsNamespaceSuggestion())
+ ? string.Format(
+ CultureInfo.InvariantCulture,
+ "{0}using System;{1}" +
+ "{2}",
+ inHeader ? Environment.NewLine : "",
+ includeCollections ? (Environment.NewLine + "using System.Collections.Generic;") : "",
+ inHeader ? "" : Environment.NewLine)
+ : "";
+ }
+}
+
+public class TypeMapper
+{
+ private const string ExternalTypeNameAttributeName = @"http://schemas.microsoft.com/ado/2006/04/codegeneration:ExternalTypeName";
+
+ private readonly System.Collections.IList _errors;
+ private readonly CodeGenerationTools _code;
+ private readonly MetadataTools _ef;
+
+ public TypeMapper(CodeGenerationTools code, MetadataTools ef, System.Collections.IList errors)
+ {
+ ArgumentNotNull(code, "code");
+ ArgumentNotNull(ef, "ef");
+ ArgumentNotNull(errors, "errors");
+
+ _code = code;
+ _ef = ef;
+ _errors = errors;
+ }
+
+ public static string FixNamespaces(string typeName)
+ {
+ return typeName.Replace("System.Data.Spatial.", "System.Data.Entity.Spatial.");
+ }
+
+ public string GetTypeName(TypeUsage typeUsage)
+ {
+ return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace: null);
+ }
+
+ public string GetTypeName(EdmType edmType)
+ {
+ return GetTypeName(edmType, isNullable: null, modelNamespace: null);
+ }
+
+ public string GetTypeName(TypeUsage typeUsage, string modelNamespace)
+ {
+ return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace);
+ }
+
+ public string GetTypeName(EdmType edmType, string modelNamespace)
+ {
+ return GetTypeName(edmType, isNullable: null, modelNamespace: modelNamespace);
+ }
+
+ public string GetTypeName(EdmType edmType, bool? isNullable, string modelNamespace)
+ {
+ if (edmType == null)
+ {
+ return null;
+ }
+
+ var collectionType = edmType as CollectionType;
+ if (collectionType != null)
+ {
+ return String.Format(CultureInfo.InvariantCulture, "ICollection<{0}>", GetTypeName(collectionType.TypeUsage, modelNamespace));
+ }
+
+ var typeName = _code.Escape(edmType.MetadataProperties
+ .Where(p => p.Name == ExternalTypeNameAttributeName)
+ .Select(p => (string)p.Value)
+ .FirstOrDefault())
+ ?? (modelNamespace != null && edmType.NamespaceName != modelNamespace ?
+ _code.CreateFullName(_code.EscapeNamespace(edmType.NamespaceName), _code.Escape(edmType)) :
+ _code.Escape(edmType));
+
+ if (edmType is StructuralType)
+ {
+ return typeName;
+ }
+
+ if (edmType is SimpleType)
+ {
+ var clrType = UnderlyingClrType(edmType);
+ if (!IsEnumType(edmType))
+ {
+ typeName = _code.Escape(clrType);
+ }
+
+ typeName = FixNamespaces(typeName);
+
+ return clrType.IsValueType && isNullable == true ?
+ String.Format(CultureInfo.InvariantCulture, "Nullable<{0}>", typeName) :
+ typeName;
+ }
+
+ throw new ArgumentException("edmType");
+ }
+
+ public Type UnderlyingClrType(EdmType edmType)
+ {
+ ArgumentNotNull(edmType, "edmType");
+
+ var primitiveType = edmType as PrimitiveType;
+ if (primitiveType != null)
+ {
+ return primitiveType.ClrEquivalentType;
+ }
+
+ if (IsEnumType(edmType))
+ {
+ return GetEnumUnderlyingType(edmType).ClrEquivalentType;
+ }
+
+ return typeof(object);
+ }
+
+ public object GetEnumMemberValue(MetadataItem enumMember)
+ {
+ ArgumentNotNull(enumMember, "enumMember");
+
+ var valueProperty = enumMember.GetType().GetProperty("Value");
+ return valueProperty == null ? null : valueProperty.GetValue(enumMember, null);
+ }
+
+ public string GetEnumMemberName(MetadataItem enumMember)
+ {
+ ArgumentNotNull(enumMember, "enumMember");
+
+ var nameProperty = enumMember.GetType().GetProperty("Name");
+ return nameProperty == null ? null : (string)nameProperty.GetValue(enumMember, null);
+ }
+
+ public System.Collections.IEnumerable GetEnumMembers(EdmType enumType)
+ {
+ ArgumentNotNull(enumType, "enumType");
+
+ var membersProperty = enumType.GetType().GetProperty("Members");
+ return membersProperty != null
+ ? (System.Collections.IEnumerable)membersProperty.GetValue(enumType, null)
+ : Enumerable.Empty();
+ }
+
+ public bool EnumIsFlags(EdmType enumType)
+ {
+ ArgumentNotNull(enumType, "enumType");
+
+ var isFlagsProperty = enumType.GetType().GetProperty("IsFlags");
+ return isFlagsProperty != null && (bool)isFlagsProperty.GetValue(enumType, null);
+ }
+
+ public bool IsEnumType(GlobalItem edmType)
+ {
+ ArgumentNotNull(edmType, "edmType");
+
+ return edmType.GetType().Name == "EnumType";
+ }
+
+ public PrimitiveType GetEnumUnderlyingType(EdmType enumType)
+ {
+ ArgumentNotNull(enumType, "enumType");
+
+ return (PrimitiveType)enumType.GetType().GetProperty("UnderlyingType").GetValue(enumType, null);
+ }
+
+ public string CreateLiteral(object value)
+ {
+ if (value == null || value.GetType() != typeof(TimeSpan))
+ {
+ return _code.CreateLiteral(value);
+ }
+
+ return string.Format(CultureInfo.InvariantCulture, "new TimeSpan({0})", ((TimeSpan)value).Ticks);
+ }
+
+ public bool VerifyCaseInsensitiveTypeUniqueness(IEnumerable types, string sourceFile)
+ {
+ ArgumentNotNull(types, "types");
+ ArgumentNotNull(sourceFile, "sourceFile");
+
+ var hash = new HashSet(StringComparer.InvariantCultureIgnoreCase);
+ if (types.Any(item => !hash.Add(item)))
+ {
+ _errors.Add(
+ new CompilerError(sourceFile, -1, -1, "6023",
+ String.Format(CultureInfo.CurrentCulture, CodeGenerationTools.GetResourceString("Template_CaseInsensitiveTypeConflict"))));
+ return false;
+ }
+ return true;
+ }
+
+ public IEnumerable GetEnumItemsToGenerate(IEnumerable itemCollection)
+ {
+ return GetItemsToGenerate(itemCollection)
+ .Where(e => IsEnumType(e));
+ }
+
+ public IEnumerable GetItemsToGenerate(IEnumerable itemCollection) where T: EdmType
+ {
+ return itemCollection
+ .OfType()
+ .Where(i => !i.MetadataProperties.Any(p => p.Name == ExternalTypeNameAttributeName))
+ .OrderBy(i => i.Name);
+ }
+
+ public IEnumerable GetAllGlobalItems(IEnumerable itemCollection)
+ {
+ return itemCollection
+ .Where(i => i is EntityType || i is ComplexType || i is EntityContainer || IsEnumType(i))
+ .Select(g => GetGlobalItemName(g));
+ }
+
+ public string GetGlobalItemName(GlobalItem item)
+ {
+ if (item is EdmType)
+ {
+ return ((EdmType)item).Name;
+ }
+ else
+ {
+ return ((EntityContainer)item).Name;
+ }
+ }
+
+ public IEnumerable GetSimpleProperties(EntityType type)
+ {
+ return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
+ }
+
+ public IEnumerable GetSimpleProperties(ComplexType type)
+ {
+ return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
+ }
+
+ public IEnumerable GetComplexProperties(EntityType type)
+ {
+ return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
+ }
+
+ public IEnumerable GetComplexProperties(ComplexType type)
+ {
+ return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
+ }
+
+ public IEnumerable GetPropertiesWithDefaultValues(EntityType type)
+ {
+ return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
+ }
+
+ public IEnumerable GetPropertiesWithDefaultValues(ComplexType type)
+ {
+ return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
+ }
+
+ public IEnumerable GetNavigationProperties(EntityType type)
+ {
+ return type.NavigationProperties.Where(np => np.DeclaringType == type);
+ }
+
+ public IEnumerable GetCollectionNavigationProperties(EntityType type)
+ {
+ return type.NavigationProperties.Where(np => np.DeclaringType == type && np.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many);
+ }
+
+ public FunctionParameter GetReturnParameter(EdmFunction edmFunction)
+ {
+ ArgumentNotNull(edmFunction, "edmFunction");
+
+ var returnParamsProperty = edmFunction.GetType().GetProperty("ReturnParameters");
+ return returnParamsProperty == null
+ ? edmFunction.ReturnParameter
+ : ((IEnumerable)returnParamsProperty.GetValue(edmFunction, null)).FirstOrDefault();
+ }
+
+ public bool IsComposable(EdmFunction edmFunction)
+ {
+ ArgumentNotNull(edmFunction, "edmFunction");
+
+ var isComposableProperty = edmFunction.GetType().GetProperty("IsComposableAttribute");
+ return isComposableProperty != null && (bool)isComposableProperty.GetValue(edmFunction, null);
+ }
+
+ public IEnumerable GetParameters(EdmFunction edmFunction)
+ {
+ return FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
+ }
+
+ public TypeUsage GetReturnType(EdmFunction edmFunction)
+ {
+ var returnParam = GetReturnParameter(edmFunction);
+ return returnParam == null ? null : _ef.GetElementType(returnParam.TypeUsage);
+ }
+
+ public bool GenerateMergeOptionFunction(EdmFunction edmFunction, bool includeMergeOption)
+ {
+ var returnType = GetReturnType(edmFunction);
+ return !includeMergeOption && returnType != null && returnType.EdmType.BuiltInTypeKind == BuiltInTypeKind.EntityType;
+ }
+}
+
+public static void ArgumentNotNull(T arg, string name) where T : class
+{
+ if (arg == null)
+ {
+ throw new ArgumentNullException(name);
+ }
+}
+#>
\ No newline at end of file
diff --git a/Tundra Core/User.cs b/Tundra Core/User.cs
new file mode 100644
index 0000000..42743a9
--- /dev/null
+++ b/Tundra Core/User.cs
@@ -0,0 +1,54 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated from a template.
+//
+// Manual changes to this file may cause unexpected behavior in your application.
+// Manual changes to this file will be overwritten if the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace TundraCore
+{
+ using System;
+ using System.Collections.Generic;
+
+ public partial class User
+ {
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
+ public User()
+ {
+ this.Accounts = new HashSet();
+ this.Goals = new HashSet();
+ this.Transactions = new HashSet();
+ }
+
+ public User(User source) : this()
+ {
+ Id = source.Id;
+ Name = source.Name;
+ Password = source.Password;
+ RequiresValidation = source.RequiresValidation;
+
+ Accounts = source.Accounts;
+ Goals = source.Goals;
+ Transactions = source.Transactions;
+ }
+
+ public int Id { get; set; }
+ public string Name { get; set; }
+ public string Password { get; set; }
+ public bool RequiresValidation { get; set; }
+
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+ public virtual ICollection Accounts { get; set; }
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+ public virtual ICollection Goals { get; set; }
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+ public virtual ICollection Transactions { get; set; }
+
+ public override string ToString()
+ {
+ return Name;
+ }
+ }
+}
diff --git a/Tundra Core/app.config b/Tundra Core/app.config
new file mode 100644
index 0000000..2b869e6
--- /dev/null
+++ b/Tundra Core/app.config
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Tundra Core/packages.config b/Tundra Core/packages.config
new file mode 100644
index 0000000..92c3667
--- /dev/null
+++ b/Tundra Core/packages.config
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/Tundra.sln b/Tundra.sln
new file mode 100644
index 0000000..38737ed
--- /dev/null
+++ b/Tundra.sln
@@ -0,0 +1,28 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 14
+VisualStudioVersion = 14.0.23107.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tundra Core", "Tundra Core\Tundra Core.csproj", "{12749B9C-17E0-4AF2-93AA-92288633BCAB}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tundra GUI", "TundraGUI\Tundra GUI.csproj", "{6D22B91E-121A-48AD-8F5C-186A21CC0E8C}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {12749B9C-17E0-4AF2-93AA-92288633BCAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {12749B9C-17E0-4AF2-93AA-92288633BCAB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {12749B9C-17E0-4AF2-93AA-92288633BCAB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {12749B9C-17E0-4AF2-93AA-92288633BCAB}.Release|Any CPU.Build.0 = Release|Any CPU
+ {6D22B91E-121A-48AD-8F5C-186A21CC0E8C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6D22B91E-121A-48AD-8F5C-186A21CC0E8C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6D22B91E-121A-48AD-8F5C-186A21CC0E8C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6D22B91E-121A-48AD-8F5C-186A21CC0E8C}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/TundraGUI/App.config b/TundraGUI/App.config
new file mode 100644
index 0000000..26463d3
--- /dev/null
+++ b/TundraGUI/App.config
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TundraGUI/App.xaml b/TundraGUI/App.xaml
new file mode 100644
index 0000000..514da75
--- /dev/null
+++ b/TundraGUI/App.xaml
@@ -0,0 +1,17 @@
+
+
+
+
+
diff --git a/TundraGUI/App.xaml.cs b/TundraGUI/App.xaml.cs
new file mode 100644
index 0000000..24eb361
--- /dev/null
+++ b/TundraGUI/App.xaml.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace TundraGUI
+{
+ ///
+ /// Interaction logic for App.xaml
+ ///
+ public partial class App : Application
+ {
+ }
+}
diff --git a/TundraGUI/CreateAccountWindow.xaml b/TundraGUI/CreateAccountWindow.xaml
new file mode 100644
index 0000000..8a323cb
--- /dev/null
+++ b/TundraGUI/CreateAccountWindow.xaml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/TundraGUI/CreateAccountWindow.xaml.cs b/TundraGUI/CreateAccountWindow.xaml.cs
new file mode 100644
index 0000000..760ab1f
--- /dev/null
+++ b/TundraGUI/CreateAccountWindow.xaml.cs
@@ -0,0 +1,123 @@
+using TundraCore;
+
+using System.Linq;
+using System.Windows;
+
+namespace TundraGUI
+{
+ ///
+ /// Interaction logic for CreateAccountWindow.xaml
+ ///
+ public partial class CreateAccountWindow : Window
+ {
+ public CreateAccountWindow()
+ {
+ InitializeComponent();
+ UpdatePasswordControls();
+ }
+
+ private void requireAuthenticationCheckbox_Checked(object sender, RoutedEventArgs e)
+ {
+ UpdatePasswordControls();
+ }
+
+ private void requireAuthenticationCheckbox_Unchecked(object sender, RoutedEventArgs e)
+ {
+ UpdatePasswordControls();
+ }
+
+ private void createAccount_Click(object sender, RoutedEventArgs e)
+ {
+ if(string.IsNullOrEmpty(userNameTextbox.Text))
+ {
+ MessageBox.Show("Please enter a username.");
+ return;
+ }
+ if((bool) requireAuthenticationCheckbox.IsChecked)
+ {
+ if(string.IsNullOrWhiteSpace(passwordBox.Password))
+ {
+ MessageBox.Show("Please enter a password.");
+ return;
+ }
+ if(passwordBox.Password != passwordConfirmBox.Password)
+ {
+ MessageBox.Show("Make sure your passwords match.");
+ return;
+ }
+
+ CreateAccount(userNameTextbox.Text, passwordBox.Password);
+ Close();
+ return;
+ }
+ CreateAccount(userNameTextbox.Text);
+ Close();
+ return;
+ }
+
+ private void CreateAccount(string name, string password)
+ {
+ using (var context = new TundraContext())
+ {
+ if(AccountExists(name))
+ {
+ MessageBox.Show("This account name already exists. Please choose another.", "Create Account - Error");
+ return;
+ }
+
+ var User = new User
+ {
+ Name = name,
+ Password = password,
+ RequiresValidation = true
+ };
+
+ context.Users.Add(User);
+ context.SaveChanges();
+ }
+ }
+
+ private void CreateAccount(string name)
+ {
+ using(var context = new TundraContext())
+ {
+ if (AccountExists(name))
+ {
+ MessageBox.Show("This account name already exists. Please choose another.", "Create Account - Error");
+ return;
+ }
+
+ var User = new User
+ {
+ Name = name,
+ Password = string.Empty,
+ RequiresValidation = false
+ };
+
+ context.Users.Add(User);
+ context.SaveChanges();
+ }
+ }
+
+ private bool AccountExists(string name)
+ {
+ using (var context = new TundraContext())
+ {
+ var query = from u in context.Users
+ where u.Name.Equals(name)
+ select u;
+ if (query.Any())
+ return true;
+ return false;
+ }
+ }
+
+ private void UpdatePasswordControls()
+ {
+ passwordLabel.IsEnabled = (bool)requireAuthenticationCheckbox.IsChecked;
+ passwordConfirmLabel.IsEnabled = (bool)requireAuthenticationCheckbox.IsChecked;
+ passwordBox.IsEnabled = (bool)requireAuthenticationCheckbox.IsChecked;
+ passwordConfirmBox.IsEnabled = (bool)requireAuthenticationCheckbox.IsChecked;
+ }
+ }
+}
diff --git a/TundraGUI/CreateFinancialAccountWindow.xaml b/TundraGUI/CreateFinancialAccountWindow.xaml
new file mode 100644
index 0000000..5b41dea
--- /dev/null
+++ b/TundraGUI/CreateFinancialAccountWindow.xaml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/TundraGUI/CreateFinancialAccountWindow.xaml.cs b/TundraGUI/CreateFinancialAccountWindow.xaml.cs
new file mode 100644
index 0000000..e4813d2
--- /dev/null
+++ b/TundraGUI/CreateFinancialAccountWindow.xaml.cs
@@ -0,0 +1,92 @@
+using TundraCore;
+
+using System;
+using System.Globalization;
+using System.Windows;
+using System.Windows.Input;
+
+namespace TundraGUI
+{
+ ///
+ /// Interaction logic for CreateFinancialAccountWindow.xaml
+ ///
+ public partial class CreateFinancialAccountWindow : Window
+ {
+ private MainWindow MainWindow;
+ public CreateFinancialAccountWindow(MainWindow win)
+ {
+ InitializeComponent();
+ MainWindow = win;
+ }
+
+ private void createButton_Click(object sender, RoutedEventArgs e)
+ {
+ if(string.IsNullOrWhiteSpace(nameTextBox.Text))
+ {
+ MessageBox.Show("Please enter an account name.", "Create Account - Account Name Error");
+ return;
+ }
+ if(string.IsNullOrWhiteSpace(balanceTextBox.Text))
+ {
+ MessageBox.Show("Please enter balance.", "Create Account - Balance Error");
+ return;
+ }
+
+ switch(accountTypeComboBox.SelectedIndex)
+ {
+ case 0:
+ using (var context = new TundraContext())
+ {
+ SavingsAccount acc = new SavingsAccount
+ {
+ UserId = MainWindow.ActiveUser.Id,
+ Name = nameTextBox.Text,
+ Balance = Convert.ToDecimal(balanceTextBox.Text)
+ };
+
+ context.Accounts.Add(acc);
+ context.SaveChanges();
+ }
+ break;
+ case 1:
+ using (var context = new TundraContext())
+ {
+ CheckingAccount acc = new CheckingAccount
+ {
+ UserId = MainWindow.ActiveUser.Id,
+ Name = nameTextBox.Text,
+ Balance = Convert.ToDecimal(balanceTextBox.Text)
+ };
+
+ context.Accounts.Add(acc);
+ context.SaveChanges();
+ }
+ break;
+ }
+ MainWindow.UpdateAccountsList();
+ Close();
+ }
+
+ private void balanceTextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
+ {
+ try
+ {
+ Convert.ToDecimal(balanceTextBox.Text, new CultureInfo("en-US"));
+ }
+ catch(Exception)
+ {
+ if (balanceTextBox.Text.Length == 0)
+ {
+ balanceTextBox.Text = string.Empty;
+ balanceTextBox.CaretIndex = 1;
+ }
+ else
+ {
+ balanceTextBox.Text = balanceTextBox.Text.Substring(0, balanceTextBox.Text.Length - 1);
+ balanceTextBox.CaretIndex = balanceTextBox.Text.Length;
+ }
+
+ }
+ }
+ }
+}
diff --git a/TundraGUI/CreateGoalWindow.xaml b/TundraGUI/CreateGoalWindow.xaml
new file mode 100644
index 0000000..296d77d
--- /dev/null
+++ b/TundraGUI/CreateGoalWindow.xaml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/TundraGUI/CreateGoalWindow.xaml.cs b/TundraGUI/CreateGoalWindow.xaml.cs
new file mode 100644
index 0000000..7c34538
--- /dev/null
+++ b/TundraGUI/CreateGoalWindow.xaml.cs
@@ -0,0 +1,130 @@
+using TundraCore;
+
+using System;
+using System.Globalization;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+
+
+namespace TundraGUI
+{
+ ///
+ /// Interaction logic for CreateGoalWindow.xaml
+ ///
+ public partial class CreateGoalWindow : Window
+ {
+ private MainWindow MainWindow;
+
+ public CreateGoalWindow(MainWindow win)
+ {
+ InitializeComponent();
+ MainWindow = win;
+ UpdateDepositControls();
+ }
+
+ private void depoitCheckbox_Click(object sender, RoutedEventArgs e)
+ {
+ UpdateDepositControls();
+ }
+
+ private void UpdateDepositControls()
+ {
+ if((bool)depositCheckBox.IsChecked)
+ {
+ depositAmountLabel.Visibility = Visibility.Visible;
+ depositAmountTextBox.Visibility = Visibility.Visible;
+ }
+ else
+ {
+ depositAmountLabel.Visibility = Visibility.Hidden;
+ depositAmountTextBox.Visibility = Visibility.Hidden;
+ }
+
+ }
+
+ private void ValidateTextBoxInputIsDecimal(TextBox sender)
+ {
+ try
+ {
+ Convert.ToDecimal(sender.Text, new CultureInfo("en-US"));
+ }
+ catch (Exception)
+ {
+ if (sender.Text.Length == 0)
+ {
+ sender.Text = string.Empty;
+ sender.CaretIndex = 1;
+ }
+ else
+ {
+ sender.Text = sender.Text.Substring(0, sender.Text.Length - 1);
+ sender.CaretIndex = sender.Text.Length;
+ }
+
+ }
+ }
+
+ private void targetAmountTextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
+ {
+ ValidateTextBoxInputIsDecimal(targetAmountTextBox);
+ }
+
+ private void depositAmountTextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
+ {
+ ValidateTextBoxInputIsDecimal(depositAmountTextBox);
+ }
+
+ private void submitButton_Click(object sender, RoutedEventArgs e)
+ {
+ if(string.IsNullOrWhiteSpace(nameTextBox.Text))
+ {
+ MessageBox.Show("Please enter a name.", "Create Goal - Name Error");
+ return;
+ }
+ if (string.IsNullOrWhiteSpace(descriptionTextBox.Text))
+ {
+ MessageBox.Show("Please enter a description.", "Create Goal - Description Error");
+ return;
+ }
+ if (string.IsNullOrWhiteSpace(targetAmountTextBox.Text))
+ {
+ MessageBox.Show("Please enter a target amount.", "Create Goal - Target Amount Error");
+ return;
+ }
+ if (deadlineDatePicker.SelectedDate == null || deadlineDatePicker.SelectedDate < DateTime.Now)
+ {
+ MessageBox.Show("Please select a deadline", "Create Goal - Deadline Error");
+ return;
+ }
+ if((bool) (depositCheckBox.IsChecked) && string.IsNullOrWhiteSpace(depositAmountTextBox.Text))
+ {
+ MessageBox.Show("Please enter a deposit amount.", "Create Goal - Deposit Error");
+ }
+
+ using (var context = new TundraContext())
+ {
+ Goal goal = new Goal
+ {
+ UserId = MainWindow.ActiveUser.Id,
+ Name = nameTextBox.Text,
+ Description = descriptionTextBox.Text,
+ TargetAmount = Convert.ToDecimal(targetAmountTextBox.Text),
+ AcruedAmount = 0,
+ Accomplished = false,
+ Created = DateTime.Now,
+ Deadline = (DateTime)deadlineDatePicker.SelectedDate,
+ Modified = DateTime.Now
+ };
+ if ((bool)(depositCheckBox.IsChecked))
+ goal.AcruedAmount += Convert.ToDecimal(depositAmountTextBox.Text);
+
+ context.Goals.Add(goal);
+ context.SaveChanges();
+
+ MainWindow.UpdateGoalsList();
+ Close();
+ }
+ }
+ }
+}
diff --git a/TundraGUI/CreateTransactionWindow.xaml b/TundraGUI/CreateTransactionWindow.xaml
new file mode 100644
index 0000000..0582e95
--- /dev/null
+++ b/TundraGUI/CreateTransactionWindow.xaml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/TundraGUI/CreateTransactionWindow.xaml.cs b/TundraGUI/CreateTransactionWindow.xaml.cs
new file mode 100644
index 0000000..a367f90
--- /dev/null
+++ b/TundraGUI/CreateTransactionWindow.xaml.cs
@@ -0,0 +1,98 @@
+using TundraCore;
+
+using System;
+using System.Globalization;
+using System.Windows;
+using System.Windows.Input;
+
+namespace TundraGUI
+{
+ ///
+ /// Interaction logic for CreateTransactionWindow.xaml
+ ///
+ public partial class CreateTransactionWindow : Window
+ {
+ private MainWindow MainWindow;
+ public CreateTransactionWindow(MainWindow mw)
+ {
+ InitializeComponent();
+ MainWindow = mw;
+ }
+
+ private void amountTextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
+ {
+ try
+ {
+ Convert.ToDecimal(amountTextBox.Text, new CultureInfo("en-US"));
+ }
+ catch (Exception)
+ {
+ if (amountTextBox.Text.Length == 0)
+ {
+ amountTextBox.Text = string.Empty;
+ amountTextBox.CaretIndex = 1;
+ }
+ else
+ {
+ amountTextBox.Text = amountTextBox.Text.Substring(0, amountTextBox.Text.Length - 1);
+ amountTextBox.CaretIndex = amountTextBox.Text.Length;
+ }
+
+ }
+ }
+
+ private void submitButton_Click(object sender, RoutedEventArgs e)
+ {
+ if(string.IsNullOrWhiteSpace(nameTextBox.Text))
+ {
+ MessageBox.Show("Please enter a name.", "Create Transaction - Name Error");
+ return;
+ }
+ if(string.IsNullOrWhiteSpace(descriptionTextBox.Text))
+ {
+ MessageBox.Show("Please enter a description.", "Create Transaction - Description Error");
+ return;
+ }
+ if(string.IsNullOrWhiteSpace(amountTextBox.Text))
+ {
+ MessageBox.Show("Please enter an amount.", "Create Transaction - Amount Error");
+ return;
+ }
+
+ switch(typeComboBox.SelectedIndex)
+ {
+ case 0:
+ using (var context = new TundraContext())
+ {
+ Income inc = new Income
+ {
+ UserId = MainWindow.ActiveUser.Id,
+ Name = nameTextBox.Text,
+ Description = descriptionTextBox.Text,
+ Amount = Convert.ToDecimal(amountTextBox.Text)
+ };
+ context.Transactions.Add(inc);
+ context.SaveChanges();
+ }
+ break;
+
+ case 1:
+ using (var context = new TundraContext())
+ {
+ Expense inc = new Expense
+ {
+ UserId = MainWindow.ActiveUser.Id,
+ Name = nameTextBox.Text,
+ Description = descriptionTextBox.Text,
+ Amount = Convert.ToDecimal(amountTextBox.Text)
+ };
+ context.Transactions.Add(inc);
+ context.SaveChanges();
+ }
+ break;
+ }
+ MainWindow.UpdateTransactionsList();
+ Close();
+ }
+ }
+}
diff --git a/TundraGUI/EditAccountWindow.xaml b/TundraGUI/EditAccountWindow.xaml
new file mode 100644
index 0000000..0bbae3f
--- /dev/null
+++ b/TundraGUI/EditAccountWindow.xaml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/TundraGUI/EditAccountWindow.xaml.cs b/TundraGUI/EditAccountWindow.xaml.cs
new file mode 100644
index 0000000..8f5e666
--- /dev/null
+++ b/TundraGUI/EditAccountWindow.xaml.cs
@@ -0,0 +1,108 @@
+using TundraCore;
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+using System.Globalization;
+
+namespace TundraGUI
+{
+ ///
+ /// Interaction logic for EditAccountWindow.xaml
+ ///
+ public partial class EditAccountWindow : Window
+ {
+ private Account Account;
+ public EditAccountWindow(Account acc)
+ {
+ InitializeComponent();
+ Account = acc;
+
+ Title += Account.Name;
+ nameTextBox.Text = Account.Name;
+ balanceTextBox.Text = Account.Balance.ToString();
+ }
+
+ private void ValidateDecimalInput(TextBox box)
+ {
+ try
+ {
+ Convert.ToDecimal(box.Text, new CultureInfo("en-US"));
+ }
+ catch (Exception)
+ {
+ if (box.Text.Length == 0)
+ {
+ box.Text = string.Empty;
+ box.CaretIndex = 1;
+ }
+ else
+ {
+ box.Text = box.Text.Substring(0, box.Text.Length - 1);
+ box.CaretIndex = box.Text.Length;
+ }
+
+ }
+ }
+
+ private void balanceTextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
+ {
+ ValidateDecimalInput(balanceTextBox);
+ }
+
+ private void saveButton_Click(object sender, RoutedEventArgs e)
+ {
+ if (string.IsNullOrWhiteSpace(nameTextBox.Text))
+ {
+ MessageBox.Show("Please enter a name.", "Edit Account - Name Error");
+ return;
+ }
+ if (string.IsNullOrWhiteSpace(balanceTextBox.Text))
+ {
+ MessageBox.Show("Please enter a balance.", "Edit Account - Balance Error");
+ return;
+ }
+
+ Account.Name = nameTextBox.Text;
+ Account.Balance = Convert.ToDecimal(balanceTextBox.Text);
+
+ using (var context = new TundraContext())
+ {
+ context.Entry(Account).State = System.Data.Entity.EntityState.Modified;
+ context.SaveChanges();
+ }
+
+ Close();
+ }
+
+ private void deleteButton_Click(object sender, RoutedEventArgs e)
+ {
+ MessageBoxResult result = MessageBox.Show("Are you sure you want to delete this account?", "Delete Account", MessageBoxButton.YesNoCancel);
+
+ if (result == MessageBoxResult.Yes)
+ {
+ using (var context = new TundraContext())
+ {
+ context.Entry(Account).State = System.Data.Entity.EntityState.Deleted;
+ context.SaveChanges();
+ Close();
+ return;
+ }
+ }
+ if (result == MessageBoxResult.No || result == MessageBoxResult.Cancel)
+ {
+ return;
+ }
+ }
+ }
+}
diff --git a/TundraGUI/EditGoalWindow.xaml b/TundraGUI/EditGoalWindow.xaml
new file mode 100644
index 0000000..4f7f4dc
--- /dev/null
+++ b/TundraGUI/EditGoalWindow.xaml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/TundraGUI/EditGoalWindow.xaml.cs b/TundraGUI/EditGoalWindow.xaml.cs
new file mode 100644
index 0000000..307177c
--- /dev/null
+++ b/TundraGUI/EditGoalWindow.xaml.cs
@@ -0,0 +1,144 @@
+using TundraCore;
+
+using System;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+using System.Globalization;
+
+namespace TundraGUI
+{
+ ///
+ /// Interaction logic for EditGoalWindow.xaml
+ ///
+ public partial class EditGoalWindow : Window
+ {
+ private Goal Goal;
+ public EditGoalWindow(Goal g)
+ {
+ InitializeComponent();
+ Goal = g;
+
+ this.Title += Goal.Name;
+
+ nameTextBox.Text = Goal.Name;
+ descriptionTextBox.Text = Goal.Description;
+ targetAmountTextBox.Text = Goal.TargetAmount.ToString();
+ acruedAmountTextBox.Text = Goal.AcruedAmount.ToString();
+ accomplishedCheckBox.IsChecked = Goal.Accomplished;
+ deadlineDatePicker.SelectedDate = Goal.Deadline;
+
+ SetTextBoxEnabled();
+ }
+
+ private void SetTextBoxEnabled()
+ {
+ nameTextBox.IsEnabled = (bool) !accomplishedCheckBox.IsChecked;
+ descriptionTextBox.IsEnabled = (bool)!accomplishedCheckBox.IsChecked;
+ targetAmountTextBox.IsEnabled = (bool)!accomplishedCheckBox.IsChecked;
+ acruedAmountTextBox.IsEnabled = (bool)!accomplishedCheckBox.IsChecked;
+ deadlineDatePicker.IsEnabled = (bool)!accomplishedCheckBox.IsChecked;
+ }
+
+ private void ValidateDecimalInput(TextBox box)
+ {
+ try
+ {
+ Convert.ToDecimal(box.Text, new CultureInfo("en-US"));
+ }
+ catch (Exception)
+ {
+ if (box.Text.Length == 0)
+ {
+ box.Text = string.Empty;
+ box.CaretIndex = 1;
+ }
+ else
+ {
+ box.Text = box.Text.Substring(0, box.Text.Length - 1);
+ box.CaretIndex = box.Text.Length;
+ }
+
+ }
+ }
+
+ private void acruedAmountTextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
+ {
+ ValidateDecimalInput(acruedAmountTextBox);
+ }
+
+ private void targetAmountTextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
+ {
+ ValidateDecimalInput(targetAmountTextBox);
+ }
+
+ private void saveButton_Click(object sender, RoutedEventArgs e)
+ {
+ if (string.IsNullOrWhiteSpace(nameTextBox.Text))
+ {
+ MessageBox.Show("Please enter a name.", "Edit Goal - Name Error");
+ return;
+ }
+ if (string.IsNullOrWhiteSpace(descriptionTextBox.Text))
+ {
+ MessageBox.Show("Please enter a description.", "Edit Goal - Description Error");
+ return;
+ }
+ if (string.IsNullOrWhiteSpace(targetAmountTextBox.Text))
+ {
+ MessageBox.Show("Please enter a target amount.", "Edit Goal - Target Amount Error");
+ return;
+ }
+ if (deadlineDatePicker.SelectedDate == null || deadlineDatePicker.SelectedDate < DateTime.Now)
+ {
+ MessageBox.Show("Please select a deadline", "Edit Goal - Deadline Error");
+ return;
+ }
+
+ Goal.Name = nameTextBox.Text;
+ Goal.Description = descriptionTextBox.Text;
+ Goal.TargetAmount = Convert.ToDecimal(targetAmountTextBox.Text);
+ Goal.AcruedAmount = Convert.ToDecimal(acruedAmountTextBox.Text);
+ Goal.Accomplished = (bool) accomplishedCheckBox.IsChecked;
+ Goal.Deadline = (DateTime) deadlineDatePicker.SelectedDate;
+
+ using (var context = new TundraContext())
+ {
+ context.Entry(Goal).State = System.Data.Entity.EntityState.Modified;
+ context.SaveChanges();
+ }
+
+ Close();
+ }
+
+ private void accomplishedCheckBox_Checked(object sender, RoutedEventArgs e)
+ {
+ SetTextBoxEnabled();
+ }
+
+ private void accomplishedCheckBox_Unchecked(object sender, RoutedEventArgs e)
+ {
+ SetTextBoxEnabled();
+ }
+
+ private void deleteButton_Click(object sender, RoutedEventArgs e)
+ {
+ MessageBoxResult result = MessageBox.Show("Are you sure you want to delete this goal?", "Delete Goal", MessageBoxButton.YesNoCancel);
+
+ if(result == MessageBoxResult.Yes)
+ {
+ using (var context = new TundraContext())
+ {
+ context.Entry(Goal).State = System.Data.Entity.EntityState.Deleted;
+ context.SaveChanges();
+ Close();
+ return;
+ }
+ }
+ if(result == MessageBoxResult.No || result == MessageBoxResult.Cancel)
+ {
+ return;
+ }
+ }
+ }
+}
diff --git a/TundraGUI/EditTransactionWindow.xaml b/TundraGUI/EditTransactionWindow.xaml
new file mode 100644
index 0000000..96b87ae
--- /dev/null
+++ b/TundraGUI/EditTransactionWindow.xaml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/TundraGUI/EditTransactionWindow.xaml.cs b/TundraGUI/EditTransactionWindow.xaml.cs
new file mode 100644
index 0000000..38cd67c
--- /dev/null
+++ b/TundraGUI/EditTransactionWindow.xaml.cs
@@ -0,0 +1,115 @@
+using TundraCore;
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+using System.Globalization;
+
+namespace TundraGUI
+{
+ ///
+ /// Interaction logic for EditTransactionWindow.xaml
+ ///
+ public partial class EditTransactionWindow : Window
+ {
+ private Transaction Transaction;
+ public EditTransactionWindow(Transaction trans)
+ {
+ InitializeComponent();
+ Transaction = trans;
+
+ Title += Transaction.Name;
+ nameTextBox.Text = Transaction.Name;
+ descriptionTextBox.Text = Transaction.Description;
+ amountTextBox.Text = Transaction.Amount.ToString();
+ }
+
+ private void saveButton_Click(object sender, RoutedEventArgs e)
+ {
+ if (string.IsNullOrWhiteSpace(nameTextBox.Text))
+ {
+ MessageBox.Show("Please enter a name.", "Edit Transaction - Name Error");
+ return;
+ }
+ if (string.IsNullOrWhiteSpace(descriptionTextBox.Text))
+ {
+ MessageBox.Show("Please enter a description.", "Edit Transaction - Description Error");
+ return;
+ }
+ if (string.IsNullOrWhiteSpace(amountTextBox.Text))
+ {
+ MessageBox.Show("Please enter an amount.", "Edit Transaction - Amount Error");
+ return;
+ }
+
+ Transaction.Name = nameTextBox.Text;
+ Transaction.Description = descriptionTextBox.Text;
+ Transaction.Amount = Convert.ToDecimal(amountTextBox.Text);
+
+ using (var context = new TundraContext())
+ {
+ context.Entry(Transaction).State = System.Data.Entity.EntityState.Modified;
+ context.SaveChanges();
+ }
+
+ Close();
+ }
+
+ private void deletebutton_Click(object sender, RoutedEventArgs e)
+ {
+ MessageBoxResult result = MessageBox.Show("Are you sure you want to delete this transaction?", "Delete Transaction", MessageBoxButton.YesNoCancel);
+
+ if (result == MessageBoxResult.Yes)
+ {
+ using (var context = new TundraContext())
+ {
+ context.Entry(Transaction).State = System.Data.Entity.EntityState.Deleted;
+ context.SaveChanges();
+ Close();
+ return;
+ }
+ }
+ if (result == MessageBoxResult.No || result == MessageBoxResult.Cancel)
+ {
+ return;
+ }
+ }
+
+ private void ValidateDecimalInput(TextBox box)
+ {
+ try
+ {
+ Convert.ToDecimal(box.Text, new CultureInfo("en-US"));
+ }
+ catch (Exception)
+ {
+ if (box.Text.Length == 0)
+ {
+ box.Text = string.Empty;
+ box.CaretIndex = 1;
+ }
+ else
+ {
+ box.Text = box.Text.Substring(0, box.Text.Length - 1);
+ box.CaretIndex = box.Text.Length;
+ }
+
+ }
+ }
+
+ private void amountTextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
+ {
+ ValidateDecimalInput(amountTextBox);
+ }
+ }
+}
diff --git a/TundraGUI/LoginWindow.xaml b/TundraGUI/LoginWindow.xaml
new file mode 100644
index 0000000..03b179e
--- /dev/null
+++ b/TundraGUI/LoginWindow.xaml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/TundraGUI/LoginWindow.xaml.cs b/TundraGUI/LoginWindow.xaml.cs
new file mode 100644
index 0000000..2affa2c
--- /dev/null
+++ b/TundraGUI/LoginWindow.xaml.cs
@@ -0,0 +1,57 @@
+using TundraCore;
+
+using System;
+using System.Linq;
+using System.Windows;
+
+namespace TundraGUI
+{
+ ///
+ /// Interaction logic for LoginWindow.xaml
+ ///
+ public partial class LoginWindow : Window
+ {
+ private MainWindow MainWindow;
+
+ public LoginWindow(MainWindow main)
+ {
+ InitializeComponent();
+ MainWindow = main;
+ }
+
+ private void newUserButton_Click(object sender, RoutedEventArgs e)
+ {
+ new CreateAccountWindow().Show();
+ }
+
+ private void submitButton_Click(object sender, RoutedEventArgs e)
+ {
+ TryLogin();
+ }
+
+ private void TryLogin()
+ {
+ using (var context = new TundraContext())
+ {
+ var user = (from u in context.Users
+ where u.Name.Equals(userNameTextBox.Text) &&
+ u.Password.Equals(passwordBox.Password)
+ select u).ToList();
+ if(!user.Any())
+ {
+ MessageBox.Show("Could not validate credentials.", "Login Error");
+ }
+ foreach(User u in user)
+ {
+ Console.WriteLine(u.Name);
+ MainWindow.LoggedIn = true;
+ MainWindow.ActiveUser = u;
+ MainWindow.Title = "Tundra - " + u.Name;
+
+ MainWindow.LoginWindow = null;
+ Close();
+ }
+ }
+ }
+ }
+}
diff --git a/TundraGUI/MainWindow.xaml b/TundraGUI/MainWindow.xaml
new file mode 100644
index 0000000..d44bed7
--- /dev/null
+++ b/TundraGUI/MainWindow.xaml
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/TundraGUI/MainWindow.xaml.cs b/TundraGUI/MainWindow.xaml.cs
new file mode 100644
index 0000000..73f8ab4
--- /dev/null
+++ b/TundraGUI/MainWindow.xaml.cs
@@ -0,0 +1,181 @@
+using TundraCore;
+
+using System.Linq;
+using System.Windows;
+using System.Collections.ObjectModel;
+
+namespace TundraGUI
+{
+ ///
+ /// Interaction logic for MainWindow.xaml
+ ///
+ public partial class MainWindow : Window
+ {
+ public bool LoggedIn = false;
+ public User ActiveUser = null;
+ public LoginWindow LoginWindow;
+
+ public ObservableCollection Accounts;
+ public ObservableCollection Goals;
+ public ObservableCollection Transactions;
+
+ public MainWindow()
+ {
+ InitializeComponent();
+
+ Accounts = new ObservableCollection();
+ Goals = new ObservableCollection();
+ Transactions = new ObservableCollection();
+
+ accountsListView.ItemsSource = Accounts;
+ goalsListView.ItemsSource = Goals;
+ transactionsListView.ItemsSource = Transactions;
+ }
+
+ private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
+ {
+ using (var context = new TundraContext())
+ {
+ context.SaveChanges();
+ }
+ Application.Current.Shutdown();
+ }
+
+ private bool GiveFocusToLoginWindow()
+ {
+ if (LoginWindow != null)
+ {
+ LoginWindow.Focus();
+ return true;
+ }
+ return false;
+ }
+
+ private void ExitMenuItem_Click(object sender, RoutedEventArgs e)
+ {
+ Close();
+ }
+
+ private void AboutMenuItem_Click(object sender, RoutedEventArgs e)
+ {
+ MessageBox.Show("Copyright 2016 Anthony Haddox");
+ }
+
+ private void NewAccountMenuItem_Click(object sender, RoutedEventArgs e)
+ {
+ if (!LoggedIn)
+ new LoginWindow(this).ShowDialog();
+ else
+ new CreateFinancialAccountWindow(this).ShowDialog();
+ }
+
+ private void NewGoalMenuItem_Click(object sender, RoutedEventArgs e)
+ {
+ if (!LoggedIn)
+ new LoginWindow(this).ShowDialog();
+ else
+ new CreateGoalWindow(this).ShowDialog();
+ }
+
+ private void NewTransactionMenuItem_Click(object sender, RoutedEventArgs e)
+ {
+ if (!LoggedIn)
+ new LoginWindow(this).ShowDialog();
+
+ new CreateTransactionWindow(this).ShowDialog();
+ }
+
+ public void UpdateAccountsList()
+ {
+ using (var context = new TundraContext())
+ {
+ Accounts.Clear();
+ var accountQuery = (from a in context.Accounts
+ where a.UserId == ActiveUser.Id
+ select a).ToList();
+
+ foreach (Account a in accountQuery)
+ {
+ Accounts.Add(a);
+ }
+ }
+ }
+
+ public void UpdateGoalsList()
+ {
+ using (var context = new TundraContext())
+ {
+ Goals.Clear();
+ var goalQuery = (from g in context.Goals
+ where g.UserId == ActiveUser.Id
+ select g).ToList();
+
+ foreach (Goal g in goalQuery)
+ {
+ Goals.Add(g);
+ }
+ }
+ }
+
+ public void UpdateTransactionsList()
+ {
+ using (var context = new TundraContext())
+ {
+ Transactions.Clear();
+ var transactionQuery = (from t in context.Transactions
+ where t.UserId == ActiveUser.Id
+ select t).ToList();
+
+ foreach (Transaction t in transactionQuery)
+ {
+ Transactions.Add(t);
+ }
+ }
+ }
+
+ private void mainWindow_Loaded(object sender, RoutedEventArgs e)
+ {
+ LoginWindow = new LoginWindow(this);
+ LoginWindow.ShowDialog();
+
+ if (LoggedIn)
+ {
+ UpdateLists();
+ }
+ }
+
+ private void UpdateLists()
+ {
+ UpdateAccountsList();
+ UpdateGoalsList();
+ UpdateTransactionsList();
+ }
+
+ private void goalsListView_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
+ {
+ if (goalsListView.SelectedIndex < 0)
+ return;
+
+ new EditGoalWindow((Goal) goalsListView.Items.GetItemAt(goalsListView.SelectedIndex)).ShowDialog();
+ UpdateGoalsList();
+ }
+
+ private void accountsListView_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
+ {
+ if (accountsListView.SelectedIndex < 0)
+ return;
+
+ new EditAccountWindow((Account) accountsListView.Items.GetItemAt(accountsListView.SelectedIndex)).ShowDialog();
+ UpdateAccountsList();
+ }
+
+ private void transactionsListView_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
+ {
+ if (transactionsListView.SelectedIndex < 0)
+ return;
+
+ new EditTransactionWindow((Transaction) transactionsListView.Items.GetItemAt(transactionsListView.SelectedIndex)).ShowDialog();
+ UpdateTransactionsList();
+ }
+ }
+}
diff --git a/TundraGUI/Properties/AssemblyInfo.cs b/TundraGUI/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..136eb58
--- /dev/null
+++ b/TundraGUI/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+using System.Reflection;
+using System.Resources;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Windows;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Tundra")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Tundra")]
+[assembly: AssemblyCopyright("Copyright © 2016")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+//In order to begin building localizable applications, set
+//CultureYouAreCodingWith in your .csproj file
+//inside a . For example, if you are using US english
+//in your source files, set the to en-US. Then uncomment
+//the NeutralResourceLanguage attribute below. Update the "en-US" in
+//the line below to match the UICulture setting in the project file.
+
+//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
+
+
+[assembly: ThemeInfo(
+ ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
+ //(used if a resource is not found in the page,
+ // or application resource dictionaries)
+ ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
+ //(used if a resource is not found in the page,
+ // app, or any theme specific resource dictionaries)
+)]
+
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/TundraGUI/Properties/Resources.Designer.cs b/TundraGUI/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..3973c86
--- /dev/null
+++ b/TundraGUI/Properties/Resources.Designer.cs
@@ -0,0 +1,71 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace TundraGUI.Properties
+{
+
+
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources
+ {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources()
+ {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if ((resourceMan == null))
+ {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TundraGUI.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture
+ {
+ get
+ {
+ return resourceCulture;
+ }
+ set
+ {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/TundraGUI/Properties/Resources.resx b/TundraGUI/Properties/Resources.resx
new file mode 100644
index 0000000..af7dbeb
--- /dev/null
+++ b/TundraGUI/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/TundraGUI/Properties/Settings.Designer.cs b/TundraGUI/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..e6de983
--- /dev/null
+++ b/TundraGUI/Properties/Settings.Designer.cs
@@ -0,0 +1,30 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace TundraGUI.Properties
+{
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+ {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default
+ {
+ get
+ {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/TundraGUI/Properties/Settings.settings b/TundraGUI/Properties/Settings.settings
new file mode 100644
index 0000000..033d7a5
--- /dev/null
+++ b/TundraGUI/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/TundraGUI/Tundra GUI.csproj b/TundraGUI/Tundra GUI.csproj
new file mode 100644
index 0000000..0750773
--- /dev/null
+++ b/TundraGUI/Tundra GUI.csproj
@@ -0,0 +1,243 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {6D22B91E-121A-48AD-8F5C-186A21CC0E8C}
+ WinExe
+ Properties
+ TundraGUI
+ Tundra GUI
+ v4.5.2
+ 512
+ {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ 4
+ true
+ false
+ C:\Users\antzy_000\Documents\
+ true
+ Disk
+ false
+ Foreground
+ 7
+ Days
+ false
+ false
+ true
+ en-US
+ Tundra
+ Anthony Haddox
+ 0
+ 1.0.0.%2a
+ true
+ true
+ true
+ true
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+ false
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+ TundraGUI.App
+
+
+ C5F53187987A057A886116D6AA5D1BA554950DCE
+
+
+ Tundra GUI_TemporaryKey.pfx
+
+
+ true
+
+
+ true
+
+
+
+ ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll
+ True
+
+
+ ..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll
+ True
+
+
+ ..\packages\MaterialDesignColors.1.1.2\lib\net45\MaterialDesignColors.dll
+ True
+
+
+ ..\packages\MaterialDesignThemes.2.1.0.657\lib\net45\MaterialDesignThemes.Wpf.dll
+ True
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 4.0
+
+
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ MSBuild:Compile
+ Designer
+
+
+ App.xaml
+ Code
+
+
+ CreateAccountWindow.xaml
+
+
+ CreateFinancialAccountWindow.xaml
+
+
+ CreateGoalWindow.xaml
+
+
+ CreateTransactionWindow.xaml
+
+
+ EditAccountWindow.xaml
+
+
+ EditGoalWindow.xaml
+
+
+ EditTransactionWindow.xaml
+
+
+ LoginWindow.xaml
+
+
+ MainWindow.xaml
+ Code
+
+
+
+
+ Code
+
+
+ True
+ True
+ Resources.resx
+
+
+ True
+ Settings.settings
+ True
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+
+
+
+ Designer
+
+
+
+
+ False
+ Microsoft .NET Framework 4.5.2 %28x86 and x64%29
+ true
+
+
+ False
+ .NET Framework 3.5 SP1
+ false
+
+
+ False
+ SQL Server 2012 Express
+ true
+
+
+
+
+ {12749b9c-17e0-4af2-93aa-92288633bcab}
+ Tundra Core
+
+
+
+
+
\ No newline at end of file
diff --git a/TundraGUI/packages.config b/TundraGUI/packages.config
new file mode 100644
index 0000000..69b98ba
--- /dev/null
+++ b/TundraGUI/packages.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file