19.1.3-ctp

This commit is contained in:
Alexander Mikhailov
2019-05-16 10:20:43 +03:00
committed by GitHub
parent 2e45b5d38f
commit a2371dfb0b
187 changed files with 32565 additions and 3985 deletions

View File

@@ -0,0 +1,69 @@
using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using DevExpress.Common;
using DevExpress.DataAnnotations;
namespace DevExpress.DevAV {
public partial class Address : ObservableObject, IDataErrorInfo {
string line;
[Display(Name = "Address")]
public string Line {
get { return line; }
set { SetPropertyValue(ref line, value); }
}
string city;
public string City {
get { return city; }
set { SetPropertyValue(ref city, value); }
}
StateEnum state;
public StateEnum State {
get { return state; }
set { SetPropertyValue(ref state, value); }
}
string zipCode;
[ZipCode, Display(Name = "Zip code")]
public string ZipCode {
get { return zipCode; }
set { SetPropertyValue(ref zipCode, value); }
}
double latitude;
public double Latitude {
get { return latitude; }
set { SetPropertyValue(ref latitude, value); }
}
double longitude;
public double Longitude {
get { return longitude; }
set { SetPropertyValue(ref longitude, value); }
}
public string CityLine {
get { return GetCityLine(City, State, ZipCode); }
}
public override string ToString() {
return string.Format("{0}, {1}", Line, CityLine);
}
#region IDataErrorInfo
string IDataErrorInfo.Error { get { return null; } }
string IDataErrorInfo.this[string columnName] {
get { return IDataErrorInfoHelper.GetErrorText(this, columnName); }
}
#endregion
internal static string GetCityLine(string city, StateEnum state, string zipCode) {
return string.Format("{0}, {1} {2}", city, state, zipCode);
}
}
public static partial class AddressHelper {
public static void UpdateAddress(Address address, string line, string city, StateEnum state, string zipCode, double latitude, double longtitude) {
address.Line = line;
address.City = city;
address.State = state;
address.ZipCode = zipCode;
address.Latitude = latitude;
address.Longitude = longtitude;
}
}
}

View File

@@ -0,0 +1,139 @@
using Microsoft.EntityFrameworkCore;
using System;
namespace DevExpress.DevAV {
[CLSCompliant(false)]
public class DevAVDb : DbContext {
public DevAVDb(string connectionStringOrName) {
connectionString = connectionStringOrName;
}
string connectionString = string.Empty;
public DevAVDb() : base() {
}
protected override void OnConfiguring(DbContextOptionsBuilder optionbuilder) {
optionbuilder.UseLazyLoadingProxies().UseSqlite(connectionString);
}
public DbSet<Customer> Customers { get; set; }
public DbSet<Employee> Employees { get; set; }
public DbSet<Product> Products { get; set; }
public DbSet<Crest> Crests { get; set; }
public DbSet<CustomerStore> CustomerStores { get; set; }
public DbSet<Order> Orders { get; set; }
public DbSet<OrderItem> OrderItems { get; set; }
public DbSet<Probation> Probations { get; set; }
public DbSet<ProductCatalog> ProductCatalogs { get; set; }
public DbSet<ProductImage> ProductImages { get; set; }
public DbSet<Quote> Quotes { get; set; }
public DbSet<QuoteItem> QuoteItems { get; set; }
public DbSet<State> States { get; set; }
public DbSet<CustomerEmployee> CustomerEmployees { get; set; }
public DbSet<Evaluation> Evaluations { get; set; }
public DbSet<Picture> Pictures { get; set; }
public DbSet<EmployeeTask> EmployeeTasks { get; set; }
public DbSet<CustomerCommunication> CustomerCommunications { get; set; }
public DbSet<TaskAttachedFile> TaskAttachedFiles { get; set; }
public DbSet<DatabaseVersion> DatabaseVersions { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder) {
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Employee>()
.Ignore(x => x.AssignedEmployeeTasks);
modelBuilder.Entity<EmployeeTask>()
.Ignore(x => x.AssignedEmployees);
modelBuilder.Entity<TaskAttachedFile>()
.HasOne(t => t.EmployeeTask)
.WithMany(p => p.AttachedFiles)
.HasForeignKey(t => t.EmployeeTaskId);
modelBuilder.Entity<EmployeeTask>()
.HasOne(x => x.AssignedEmployee)
.WithMany(x => x.AssignedTasks);
modelBuilder.Entity<EmployeeTask>()
.HasOne(x => x.Owner)
.WithMany(x => x.OwnedTasks);
modelBuilder.Entity<EmployeeTask>()
.HasOne(x => x.CustomerEmployee)
.WithMany(x => x.EmployeeTasks);
modelBuilder.Entity<Employee>()
.HasOne(x => x.Picture)
.WithMany(x => x.Employees);
modelBuilder.Entity<Employee>()
.HasOne(x => x.ProbationReason)
.WithMany(x => x.Employees)
.HasForeignKey(x => x.ProbationReason_Id);
modelBuilder.Entity<Evaluation>()
.HasOne(x => x.CreatedBy)
.WithMany(x => x.EvaluationsCreatedBy);
modelBuilder.Entity<CustomerEmployee>()
.HasOne(x => x.CustomerStore)
.WithMany(x => x.CustomerEmployees);
modelBuilder.Entity<CustomerEmployee>()
.HasOne(x => x.Picture)
.WithMany(x => x.CustomerEmployees);
modelBuilder.Entity<CustomerStore>()
.HasOne(x => x.Crest)
.WithMany(x => x.CustomerStores);
modelBuilder.Entity<Order>()
.HasOne(x => x.Employee)
.WithMany(x => x.Orders);
modelBuilder.Entity<Order>()
.HasOne(x => x.Store)
.WithMany(x => x.Orders);
modelBuilder.Entity<Product>()
.HasOne(x => x.Engineer)
.WithMany(x => x.Products);
modelBuilder.Entity<Product>()
.HasOne(x => x.PrimaryImage)
.WithMany(x => x.Products);
modelBuilder.Entity<Product>()
.HasOne(x => x.Support)
.WithMany(x => x.SupportedProducts);
modelBuilder.Entity<ProductImage>()
.HasOne(x => x.Picture)
.WithMany(x => x.ProductImages);
modelBuilder.Entity<Quote>()
.HasOne(x => x.CustomerStore)
.WithMany(x => x.Quotes);
modelBuilder.Entity<Quote>()
.HasOne(x => x.Employee)
.WithMany(x => x.Quotes);
modelBuilder.Entity<QuoteItem>()
.HasOne(x => x.Product)
.WithMany(x => x.QuoteItems);
modelBuilder.Entity<CustomerCommunication>()
.HasOne(x => x.CustomerEmployee)
.WithMany(x => x.CustomerCommunications);
modelBuilder.Entity<CustomerCommunication>()
.HasOne(x => x.Employee)
.WithMany(x => x.Employees);
}
}
public class DatabaseVersion : DatabaseObject {
public DateTime Date { get; set; }
}
}

View File

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Text;
namespace DevExpress.DevAV {
public class ObservableObject : INotifyPropertyChanged {
public event PropertyChangedEventHandler PropertyChanged;
void RaisePropertyChangedEvent(string propertyName) {
var handler = PropertyChanged;
if(handler != null)
handler(this, new PropertyChangedEventArgs(propertyName));
}
protected void SetPropertyValue<T>(ref T valueHolder, T newValue, [CallerMemberName]string propertyName = null) {
if(object.Equals(valueHolder, newValue))
return;
valueHolder = newValue;
RaisePropertyChangedEvent(propertyName);
}
}
}