in order to use EF7 commands

This commit is contained in:
2018-04-18 18:15:40 +02:00
parent 86fa893796
commit bef5c2abe5
474 changed files with 316 additions and 181 deletions

View File

@ -1,19 +0,0 @@
using System;
namespace Yavsc.Attributes
{
public class ActivityBillingAttribute : Attribute
{
public string BillingCode { get; private set; }
/// <summary>
/// Identifie une entité de facturation
/// </summary>
/// <param name="billingCode">Code de facturation,
/// Il doit avoir une valeur unique par usage.
/// </param>
public ActivityBillingAttribute(string billingCode) {
BillingCode = billingCode;
}
}
}

View File

@ -1,9 +0,0 @@
using System;
namespace Yavsc.Attributes
{
public class ActivitySettingsAttribute : Attribute
{
}
}

View File

@ -1,16 +0,0 @@
using System.Resources;
namespace Yavsc.Attributes.Validation
{
public class YaRegularExpression : System.ComponentModel.DataAnnotations.RegularExpressionAttribute {
public YaRegularExpression(string pattern): base (pattern)
{
this.ErrorMessage = pattern;
}
public override string FormatErrorMessage(string name)
{
return ResourcesHelpers.GlobalLocalizer[this.ErrorMessageResourceName];
}
}
}

View File

@ -1,37 +0,0 @@
using System;
namespace Yavsc.Attributes.Validation
{
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)]
public class YaRequiredAttribute : YaValidationAttribute
{
/// <summary>
/// Gets or sets a flag indicating whether the attribute should allow empty strings.
/// </summary>
public bool AllowEmptyStrings { get; set; }
public YaRequiredAttribute (string msg) : base()
{
ErrorMessage = msg;
}
public YaRequiredAttribute ()
{
this.ErrorMessage = ResourcesHelpers.GlobalLocalizer["RequiredField"];
}
public override bool IsValid(object value) {
if (value == null) {
return false;
}
// only check string length if empty strings are not allowed
var stringValue = value as string;
if (stringValue != null && !AllowEmptyStrings) {
return stringValue.Trim().Length != 0;
}
return true;
}
}
}

View File

@ -1,58 +0,0 @@
namespace Yavsc.Attributes.Validation
{
public class YaStringLength: YaValidationAttribute
{
public long MinLen { get; set; } = -1;
private long maxLen;
public YaStringLength(long maxLen) : base(
()=>string.Format(
ResourcesHelpers.GlobalLocalizer["BadStringLength"],
maxLen))
{
this.maxLen = maxLen;
}
private long excedent;
private long manquant;
public override bool IsValid(object value) {
if (value == null) {
return false;
}
string stringValue = value as string;
if (stringValue==null) return false;
if (MinLen>=0)
{
if (stringValue.Length<MinLen)
{
manquant = MinLen-stringValue.Length;
}
return false;
}
if (maxLen>=0)
{
if (stringValue.Length>maxLen) {
excedent = stringValue.Length-maxLen;
return false;
}
}
return true;
}
public override string FormatErrorMessage(string name)
{
if (MinLen<0) {
// DetailledMaxStringLength
return string.Format(
ResourcesHelpers.GlobalLocalizer["DetailledMaxStringLength"],
maxLen,
excedent);
} else
return string.Format(
ResourcesHelpers.GlobalLocalizer["DetailledMinMaxStringLength"],
MinLen,
maxLen,
manquant,
excedent);
}
}
}

View File

@ -1,22 +0,0 @@
using System;
namespace Yavsc.Attributes.Validation
{
public class YaValidationAttribute : System.ComponentModel.DataAnnotations.ValidationAttribute
{
public YaValidationAttribute() : base(()=> ResourcesHelpers.GlobalLocalizer["validationError"])
{
}
public YaValidationAttribute(Func<string> acr): base(acr)
{
}
public override string FormatErrorMessage(string name)
{
return ResourcesHelpers.GlobalLocalizer[name];
}
}
}