Skip to content

Commit

Permalink
update to not null
Browse files Browse the repository at this point in the history
  • Loading branch information
olmobrutall committed Feb 13, 2019
1 parent f2d4fd9 commit d61f242
Show file tree
Hide file tree
Showing 30 changed files with 257 additions and 292 deletions.
2 changes: 1 addition & 1 deletion Extensions
Submodule Extensions updated 367 files
2 changes: 1 addition & 1 deletion Framework
Submodule Framework updated 302 files
18 changes: 9 additions & 9 deletions Southwind.Entities/Address.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand All @@ -11,22 +11,22 @@ namespace Southwind.Entities
[Serializable]
public class AddressEmbedded : EmbeddedEntity
{
[StringLengthValidator(AllowNulls = false, Min = 3, Max = 60, MultiLine = true)]
[StringLengthValidator(Min = 3, Max = 60, MultiLine = true)]
public string Address { get; set; }

[StringLengthValidator(AllowNulls = false, Min = 3, Max = 15)]
[StringLengthValidator(Min = 3, Max = 15)]
public string City { get; set; }

[StringLengthValidator(AllowNulls = true, Min = 2, Max = 15)]
public string Region { get; set; }
[StringLengthValidator(Min = 2, Max = 15)]
public string? Region { get; set; }

[StringLengthValidator(AllowNulls = true, Min = 3, Max = 10)]
public string PostalCode { get; set; }
[StringLengthValidator(Min = 3, Max = 10)]
public string? PostalCode { get; set; }

[StringLengthValidator(AllowNulls = false, Min = 2, Max = 15)]
[StringLengthValidator(Min = 2, Max = 15)]
public string Country { get; set; }

protected override string PropertyValidation(PropertyInfo pi)
protected override string? PropertyValidation(PropertyInfo pi)
{
if (pi.Name == nameof(PostalCode))
{
Expand Down
14 changes: 4 additions & 10 deletions Southwind.Entities/ApplicationConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand All @@ -16,32 +16,26 @@ namespace Southwind.Entities
[Serializable, EntityKind(EntityKind.Main, EntityData.Master)]
public class ApplicationConfigurationEntity : Entity
{
[StringLengthValidator(AllowNulls = false, Min = 3, Max = 100)]
[StringLengthValidator(Min = 3, Max = 100)]
public string Environment { get; set; }

[StringLengthValidator(AllowNulls = false, Min = 3, Max = 100)]
[StringLengthValidator(Min = 3, Max = 100)]
public string DatabaseName { get; set; }

/*Email*/
[NotNullValidator]
public EmailConfigurationEmbedded Email { get; set; }

[NotNullValidator]/*Smtp*/
public SmtpConfigurationEntity SmtpConfiguration { get; set; }

/*Sms*/
[NotNullValidator]
public SMSConfigurationEmbedded Sms { get; set; }

/*AuthTokens*/
[NotNullValidator]
public AuthTokenConfigurationEmbedded AuthTokens { get; set; }

/*Workflow*/
[NotNullValidator]
public WorkflowConfigurationEmbedded Workflow { get; set; }

[NotNullValidator]
public FoldersConfigurationEmbedded Folders { get; set; }
}

Expand All @@ -63,7 +57,7 @@ public static class SouthwindGroup
public class FoldersConfigurationEmbedded : EmbeddedEntity
{
/*Predictor*/
[StringLengthValidator(AllowNulls = false, Max = 300), FileNameValidator]
[StringLengthValidator(Max = 300), FileNameValidator]
public string PredictorModelFolder { get; set; }
}
}
27 changes: 13 additions & 14 deletions Southwind.Entities/Customer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
Expand All @@ -12,14 +12,13 @@ namespace Southwind.Entities
[Serializable, PrimaryKey(typeof(Guid))]
public abstract class CustomerEntity : Entity
{
[NotNullValidator]
public AddressEmbedded Address { get; set; }

[StringLengthValidator(AllowNulls = false, Min = 3, Max = 24), TelephoneValidator]
[StringLengthValidator(Min = 3, Max = 24), TelephoneValidator]
public string Phone { get; set; }

[StringLengthValidator(AllowNulls = true, Min = 3, Max = 24), TelephoneValidator]
public string Fax { get; set; }
[StringLengthValidator(Min = 3, Max = 24), TelephoneValidator]
public string? Fax { get; set; }

public static readonly SessionVariable<CustomerEntity> CurrentCustomerVariable = Statics.SessionVariable<CustomerEntity>("Customer");
public static CustomerEntity Current
Expand All @@ -39,21 +38,21 @@ public enum CustomerQuery
[Serializable, EntityKind(EntityKind.Shared, EntityData.Transactional)]
public class PersonEntity : CustomerEntity
{
[StringLengthValidator(AllowNulls = false, Min = 3, Max = 40)]
[StringLengthValidator(Min = 3, Max = 40)]
public string FirstName { get; set; }

[StringLengthValidator(AllowNulls = false, Min = 3, Max = 40)]
[StringLengthValidator(Min = 3, Max = 40)]
public string LastName { get; set; }

[StringLengthValidator(AllowNulls = true, Min = 3, Max = 10)]
public string Title { get; set; }
[StringLengthValidator(Min = 3, Max = 10)]
public string? Title { get; set; }

[DateTimePrecisionValidator(DateTimePrecision.Days)]
public DateTime? DateOfBirth { get; set; }

public bool Corrupt { get; set; }

public override Dictionary<Guid, IntegrityCheck> EntityIntegrityCheck()
public override Dictionary<Guid, IntegrityCheck>? EntityIntegrityCheck()
{
using (this.Corrupt ? Corruption.AllowScope() : null)
{
Expand Down Expand Up @@ -90,13 +89,13 @@ static PersonEntity()
[Serializable, EntityKind(EntityKind.Shared, EntityData.Transactional)]
public class CompanyEntity : CustomerEntity
{
[StringLengthValidator(AllowNulls = true, Min = 3, Max = 40)]
public string CompanyName { get; set; }
[StringLengthValidator(Min = 3, Max = 40)]
public string? CompanyName { get; set; }

[StringLengthValidator(AllowNulls = false, Min = 3, Max = 30)]
[StringLengthValidator(Min = 3, Max = 30)]
public string ContactName { get; set; }

[StringLengthValidator(AllowNulls = false, Min = 3, Max = 30)]
[StringLengthValidator(Min = 3, Max = 30)]
public string ContactTitle { get; set; }

static Expression<Func<CompanyEntity, string>> ToStringExpression = e => e.CompanyName;
Expand Down
42 changes: 20 additions & 22 deletions Southwind.Entities/Employee.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand All @@ -16,41 +16,40 @@ namespace Southwind.Entities
[Serializable, EntityKind(EntityKind.Main, EntityData.Master)]
public class EmployeeEntity : Entity
{
[StringLengthValidator(AllowNulls = false, Min = 3, Max = 20)]
[StringLengthValidator(Min = 3, Max = 20)]
public string LastName { get; set; }

[StringLengthValidator(AllowNulls = false, Min = 3, Max = 10)]
[StringLengthValidator(Min = 3, Max = 10)]
public string FirstName { get; set; }

[StringLengthValidator(AllowNulls = true, Min = 3, Max = 30)]
public string Title { get; set; }
[StringLengthValidator(Min = 3, Max = 30)]
public string? Title { get; set; }

[StringLengthValidator(AllowNulls = true, Min = 3, Max = 25)]
public string TitleOfCourtesy { get; set; }
[StringLengthValidator(Min = 3, Max = 25)]
public string? TitleOfCourtesy { get; set; }

[DateTimePrecisionValidator(DateTimePrecision.Days)]
public DateTime? BirthDate { get; set; }

public DateTime? HireDate { get; set; }

[NotNullValidator]
public AddressEmbedded Address { get; set; }

[StringLengthValidator(AllowNulls = true, Min = 3, Max = 25), TelephoneValidator]
public string HomePhone { get; set; }
[StringLengthValidator(Min = 3, Max = 25), TelephoneValidator]
public string? HomePhone { get; set; }

[StringLengthValidator(AllowNulls = true, Min = 3, Max = 4), TelephoneValidator]
public string Extension { get; set; }
[StringLengthValidator(Min = 3, Max = 4), TelephoneValidator]
public string? Extension { get; set; }

public Lite<FileEntity> Photo { get; set; }
public Lite<FileEntity>? Photo { get; set; }

[StringLengthValidator(AllowNulls = true, Min = 3, MultiLine = true)]
public string Notes { get; set; }
[StringLengthValidator(Min = 3, MultiLine = true)]
public string? Notes { get; set; }

public Lite<EmployeeEntity> ReportsTo { get; set; }
public Lite<EmployeeEntity>? ReportsTo { get; set; }

[StringLengthValidator(AllowNulls = true, Min = 3, Max = 255), URLValidator]
public string PhotoPath { get; set; }
[StringLengthValidator(Min = 3, Max = 255), URLValidator]
public string? PhotoPath { get; set; }

[NoRepeatValidator, NoRepeatValidator]
public MList<TerritoryEntity> Territories { get; set; } = new MList<TerritoryEntity>();
Expand All @@ -60,7 +59,7 @@ public override string ToString()
return "{0} {1}".FormatWith(FirstName, LastName);
}

public static Lite<EmployeeEntity> Current
public static Lite<EmployeeEntity>? Current
{
get { return UserEntity.Current.Mixin<UserEmployeeMixin>().Employee; } //get { return null; }
} //Current
Expand All @@ -75,11 +74,10 @@ public static class EmployeeOperation
[Serializable, EntityKind(EntityKind.String, EntityData.Master)]
public class TerritoryEntity : Entity
{
[NotNullValidator]
public RegionEntity Region { get; set; }

[UniqueIndex]
[StringLengthValidator(AllowNulls = false, Min = 3, Max = 100)]
[StringLengthValidator(Min = 3, Max = 100)]
public string Description { get; set; }

static Expression<Func<TerritoryEntity, string>> ToStringExpression = e => e.Description;
Expand All @@ -100,7 +98,7 @@ public static class TerritoryOperation
public class RegionEntity : Entity
{
[UniqueIndex]
[StringLengthValidator(AllowNulls = false, Min = 3, Max = 50)]
[StringLengthValidator(Min = 3, Max = 50)]
public string Description { get; set; }

static Expression<Func<RegionEntity, string>> ToStringExpression = e => e.Description;
Expand Down
55 changes: 12 additions & 43 deletions Southwind.Entities/Order.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand All @@ -24,10 +24,8 @@ public OrderEntity()
}

[ImplementedBy(typeof(CompanyEntity), typeof(PersonEntity))]
[NotNullValidator]
public CustomerEntity Customer { get; set; }

[NotNullValidator]
public Lite<EmployeeEntity> Employee { get; set; }

public DateTime OrderDate { get; set; }
Expand All @@ -38,19 +36,18 @@ public OrderEntity()

public DateTime? CancelationDate { get; set; }

public Lite<ShipperEntity> ShipVia { get; set; }
public Lite<ShipperEntity>? ShipVia { get; set; }

[StringLengthValidator(AllowNulls = true, Min = 3, Max = 40)]
public string ShipName { get; set; }
[StringLengthValidator(Min = 3, Max = 40)]
public string? ShipName { get; set; }

[NotNullValidator]
public AddressEmbedded ShipAddress { get; set; }

[Unit("Kg")]
public decimal Freight { get; set; }

[NotifyChildProperty, NotifyCollectionChanged]
[NotNullValidator, NoRepeatValidator, PreserveOrder]
[NoRepeatValidator, PreserveOrder]
public MList<OrderDetailEmbedded> Details { get; set; } = new MList<OrderDetailEmbedded>();

static Expression<Func<OrderEntity, decimal>> TotalPriceExpression =
Expand All @@ -65,9 +62,8 @@ public decimal TotalPrice

public OrderState State { get; set; }

protected override string ChildPropertyValidation(ModifiableEntity sender, PropertyInfo pi)
protected override string? ChildPropertyValidation(ModifiableEntity sender, PropertyInfo pi)
{

if (sender is OrderDetailEmbedded details && !IsLegacy && pi.Name == nameof(details.Discount))
{
if ((details.Discount * 100.0m) % 5.0m != 0)
Expand All @@ -89,7 +85,7 @@ protected override void ChildPropertyChanged(object sender, PropertyChangedEvent
Notify(() => TotalPrice);
}

protected override string PropertyValidation(PropertyInfo pi)
protected override string? PropertyValidation(PropertyInfo pi)
{
return stateValidator.Validate(this, pi);
}
Expand Down Expand Up @@ -139,9 +135,8 @@ public static class OrderOperation
}

[Serializable]
public class OrderDetailEmbedded : EmbeddedEntity, IEditableObject
public class OrderDetailEmbedded : EmbeddedEntity
{
[NotNullValidator]
public Lite<ProductEntity> Product { get; set; }

decimal unitPrice;
Expand Down Expand Up @@ -186,42 +181,16 @@ public decimal SubTotalPrice
{
get { return SubTotalPriceExpression.Evaluate(this); }
}

[Ignore]
OrderDetailEmbedded clone;

public void BeginEdit()
{
clone = new OrderDetailEmbedded
{
Product = Product,
Quantity = quantity,
UnitPrice = unitPrice,
Discount = discount
};
}

public void CancelEdit()
{
Product = clone.Product;
Quantity = clone.quantity;
Discount = clone.discount;
}

public void EndEdit()
{
clone = null;
}
}

[Serializable, EntityKind(EntityKind.Main, EntityData.Master)]
public class ShipperEntity : Entity
{
[UniqueIndex]
[StringLengthValidator(AllowNulls = false, Min = 3, Max = 100)]
[StringLengthValidator(Min = 3, Max = 100)]
public string CompanyName { get; set; }

[StringLengthValidator(AllowNulls = false, Min = 3, Max = 24), TelephoneValidator]
[StringLengthValidator(Min = 3, Max = 24), TelephoneValidator]
public string Phone { get; set; }

static Expression<Func<ShipperEntity, string>> ToStringExpression = e => e.CompanyName;
Expand Down Expand Up @@ -260,9 +229,9 @@ public static class OrderProcess
public class OrderFilterModel : ModelEntity
{
[ImplementedBy(typeof(PersonEntity), typeof(CompanyEntity))]
public Lite<CustomerEntity> Customer { get; set; }
public Lite<CustomerEntity>? Customer { get; set; }

public Lite<EmployeeEntity> Employee { get; set; }
public Lite<EmployeeEntity>? Employee { get; set; }

[DaysPrecisionValidator]
public DateTime? MinOrderDate { get; set; }
Expand Down
Loading

0 comments on commit d61f242

Please sign in to comment.