diff --git a/src/Yavsc.Abstract/Attributes/Validation/YaRequiredAttribute.cs b/src/Yavsc.Abstract/Attributes/Validation/YaRequiredAttribute.cs
index c73d4d38..9f753c20 100644
--- a/src/Yavsc.Abstract/Attributes/Validation/YaRequiredAttribute.cs
+++ b/src/Yavsc.Abstract/Attributes/Validation/YaRequiredAttribute.cs
@@ -14,10 +14,12 @@ namespace Yavsc.Attributes.Validation
{
ErrorMessage = msg;
}
- public YaRequiredAttribute () : base("RequiredField")
+ public YaRequiredAttribute () : base("Required Field")
{
-
+ ErrorMessageResourceType = typeof(Yavsc.Attributes.Validation.Resources);
+ ErrorMessageResourceName = "FieldRequired";
}
+
public override bool IsValid(object value) {
if (value == null) {
return false;
diff --git a/src/Yavsc.Abstract/Attributes/Validation/YaStringLength.cs b/src/Yavsc.Abstract/Attributes/Validation/YaStringLength.cs
index a1193614..ab356085 100644
--- a/src/Yavsc.Abstract/Attributes/Validation/YaStringLength.cs
+++ b/src/Yavsc.Abstract/Attributes/Validation/YaStringLength.cs
@@ -20,7 +20,7 @@ namespace Yavsc.Attributes.Validation
void UseDefaultErrorMessage()
{
if (ErrorMessageResourceType==null) {
- ErrorMessageResourceType = typeof(YaStringLength);
+ ErrorMessageResourceType = typeof(Yavsc.Attributes.Validation.Resources);
ErrorMessageResourceName = "InvalidStringLength";
}
}
diff --git a/src/Yavsc.Abstract/FileSystem/AbstractFileSystemHelpers.cs b/src/Yavsc.Abstract/FileSystem/AbstractFileSystemHelpers.cs
index ae605168..f66e88fd 100644
--- a/src/Yavsc.Abstract/FileSystem/AbstractFileSystemHelpers.cs
+++ b/src/Yavsc.Abstract/FileSystem/AbstractFileSystemHelpers.cs
@@ -12,14 +12,24 @@ namespace Yavsc.Helpers
public static string UserBillsDirName { set; get; }
public static string UserFilesDirName { set; get; }
+ ///
+ /// Is Valid this Path?
+ /// Return true when given value is a valid user file sub-path,
+ /// regarding chars used to specify it.
+ ///
+ /// Path to validate
+ ///
public static bool IsValidYavscPath(this string path)
{
if (string.IsNullOrEmpty(path)) return true;
+ // disallow full path specification
+ if (path[0]==Path.DirectorySeparatorChar) return false;
foreach (var name in path.Split(Path.DirectorySeparatorChar))
{
if (!IsValidDirectoryName(name) || name.Equals("..") || name.Equals("."))
return false;
}
+ // disallow trailling slash
if (path[path.Length-1]==RemoteDirectorySeparator) return false;
return true;
}
diff --git a/src/Yavsc.Abstract/FileSystem/FsOperationInfo.cs b/src/Yavsc.Abstract/FileSystem/FsOperationInfo.cs
new file mode 100644
index 00000000..5a595a07
--- /dev/null
+++ b/src/Yavsc.Abstract/FileSystem/FsOperationInfo.cs
@@ -0,0 +1,7 @@
+namespace Yavsc.Helpers
+{
+ public class FsOperationInfo {
+ public bool Done { get; set; } = false;
+ public string Error { get; set; }
+ }
+}
diff --git a/src/Yavsc.Abstract/FileSystem/UserFileInfo.cs b/src/Yavsc.Abstract/FileSystem/RemoteFileInfo.cs
similarity index 94%
rename from src/Yavsc.Abstract/FileSystem/UserFileInfo.cs
rename to src/Yavsc.Abstract/FileSystem/RemoteFileInfo.cs
index 027161a2..76cb17eb 100644
--- a/src/Yavsc.Abstract/FileSystem/UserFileInfo.cs
+++ b/src/Yavsc.Abstract/FileSystem/RemoteFileInfo.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
namespace Yavsc.ViewModels
{
@@ -11,7 +11,6 @@ namespace Yavsc.ViewModels
public DateTime CreationTime { get; set; }
public DateTime LastModified { get; set; }
-
}
diff --git a/src/Yavsc.Abstract/Identity/BlackListedUserName.cs b/src/Yavsc.Abstract/Identity/BlackListedUserName.cs
index d4548902..769a6494 100644
--- a/src/Yavsc.Abstract/Identity/BlackListedUserName.cs
+++ b/src/Yavsc.Abstract/Identity/BlackListedUserName.cs
@@ -1,11 +1,12 @@
using System.ComponentModel.DataAnnotations;
+using Yavsc.Attributes.Validation;
namespace Yavsc.Models.Identity
{
public class BlackListedUserName : IWatchedUserName {
[Key]
- [StringLength(1024)]
+ [YaStringLength(1024)]
public string Name { get; set;}
}
diff --git a/src/Yavsc.Abstract/Identity/ReservedUserName.cs b/src/Yavsc.Abstract/Identity/ReservedUserName.cs
index 52bf8225..c22fe2ef 100644
--- a/src/Yavsc.Abstract/Identity/ReservedUserName.cs
+++ b/src/Yavsc.Abstract/Identity/ReservedUserName.cs
@@ -1,11 +1,12 @@
using System.ComponentModel.DataAnnotations;
+using Yavsc.Attributes.Validation;
namespace Yavsc.Models.Identity
{
public class ReservedUserName : IWatchedUserName {
[Key]
- [StringLength(1024)]
+ [YaStringLength(1024)]
public string Name { get; set;}
}
diff --git a/src/Yavsc.Abstract/Makefile b/src/Yavsc.Abstract/Makefile
index f998b0cd..1e3da53a 100644
--- a/src/Yavsc.Abstract/Makefile
+++ b/src/Yavsc.Abstract/Makefile
@@ -1,6 +1,6 @@
SOURCE_DIR=$(HOME)/workspace/yavsc
MAKEFILE_DIR=$(SOURCE_DIR)/scripts/build/make
-BASERESX=Resources/Yavsc.Attributes.Validation.YaStringLength.resx
+BASERESX=Resources/Yavsc.Attributes.Validation.Resources.resx
BASERESXGEN=$(BASERESX:.resx=.Designer.cs)
include $(MAKEFILE_DIR)/versioning.mk
include $(MAKEFILE_DIR)/dnx.mk
diff --git a/src/Yavsc.Abstract/Resources/Yavsc.Attributes.Validation.Resources pt.resx b/src/Yavsc.Abstract/Resources/Yavsc.Attributes.Validation.Resources pt.resx
new file mode 100644
index 00000000..82f63d19
--- /dev/null
+++ b/src/Yavsc.Abstract/Resources/Yavsc.Attributes.Validation.Resources pt.resx
@@ -0,0 +1,67 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ Por favor, preencha este campo
+ comprimento inválido da corrente ({0}..{1})
+
+
\ No newline at end of file
diff --git a/src/Yavsc.Abstract/Resources/Yavsc.Attributes.Validation.YaStringLength.Designer.cs b/src/Yavsc.Abstract/Resources/Yavsc.Attributes.Validation.Resources.Designer.cs
similarity index 68%
rename from src/Yavsc.Abstract/Resources/Yavsc.Attributes.Validation.YaStringLength.Designer.cs
rename to src/Yavsc.Abstract/Resources/Yavsc.Attributes.Validation.Resources.Designer.cs
index dd984010..2ac3ea78 100644
--- a/src/Yavsc.Abstract/Resources/Yavsc.Attributes.Validation.YaStringLength.Designer.cs
+++ b/src/Yavsc.Abstract/Resources/Yavsc.Attributes.Validation.Resources.Designer.cs
@@ -1,12 +1,12 @@
-//------------------------------------------------------------------------------
-//
-// 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.
-//
-//------------------------------------------------------------------------------
+// ------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Mono Runtime Version: 4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+// ------------------------------------------------------------------------------
namespace Yavsc.Attributes.Validation {
using System;
@@ -16,7 +16,7 @@ namespace Yavsc.Attributes.Validation {
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- public partial class YaStringLength {
+ public partial class Resources {
private static System.Resources.ResourceManager resourceMan;
@@ -26,7 +26,7 @@ namespace Yavsc.Attributes.Validation {
public static System.Resources.ResourceManager ResourceManager {
get {
if (object.Equals(null, resourceMan)) {
- System.Resources.ResourceManager temp = new System.Resources.ResourceManager(("Yavsc.Abstract.Resources." + "Yavsc.Attributes.Validation.YaStringLength"), typeof(YaStringLength).GetTypeInfo().Assembly);
+ System.Resources.ResourceManager temp = new System.Resources.ResourceManager(("Yavsc.Abstract.Resources." + "Yavsc.Attributes.Validation.Resources"), typeof(Resources).GetTypeInfo().Assembly);
resourceMan = temp;
}
return resourceMan;
@@ -43,6 +43,12 @@ namespace Yavsc.Attributes.Validation {
}
}
+ public static string FieldRequired {
+ get {
+ return ResourceManager.GetString("FieldRequired", resourceCulture);
+ }
+ }
+
public static string InvalidStringLength {
get {
return ResourceManager.GetString("InvalidStringLength", resourceCulture);
diff --git a/src/Yavsc.Abstract/Resources/Yavsc.Attributes.Validation.YaStringLength.en.resx b/src/Yavsc.Abstract/Resources/Yavsc.Attributes.Validation.Resources.en.resx
similarity index 97%
rename from src/Yavsc.Abstract/Resources/Yavsc.Attributes.Validation.YaStringLength.en.resx
rename to src/Yavsc.Abstract/Resources/Yavsc.Attributes.Validation.Resources.en.resx
index 0355a149..4ceb9e7d 100644
--- a/src/Yavsc.Abstract/Resources/Yavsc.Attributes.Validation.YaStringLength.en.resx
+++ b/src/Yavsc.Abstract/Resources/Yavsc.Attributes.Validation.Resources.en.resx
@@ -61,6 +61,6 @@
+ Please, fill in this field
Invalid string length ({0}..{1})
-
\ No newline at end of file
diff --git a/src/Yavsc.Abstract/Resources/Yavsc.Attributes.Validation.YaStringLength.resx b/src/Yavsc.Abstract/Resources/Yavsc.Attributes.Validation.Resources.resx
similarity index 97%
rename from src/Yavsc.Abstract/Resources/Yavsc.Attributes.Validation.YaStringLength.resx
rename to src/Yavsc.Abstract/Resources/Yavsc.Attributes.Validation.Resources.resx
index 48cf099c..5191f9de 100644
--- a/src/Yavsc.Abstract/Resources/Yavsc.Attributes.Validation.YaStringLength.resx
+++ b/src/Yavsc.Abstract/Resources/Yavsc.Attributes.Validation.Resources.resx
@@ -61,6 +61,6 @@
+ Veuillez renseigner ce champ
Longueur de chaine invalide ({0}..{1})
-
\ No newline at end of file
diff --git a/src/Yavsc.Server/Models/Bank/BankIdentity.cs b/src/Yavsc.Server/Models/Bank/BankIdentity.cs
index fe960d49..cb08a3a5 100644
--- a/src/Yavsc.Server/Models/Bank/BankIdentity.cs
+++ b/src/Yavsc.Server/Models/Bank/BankIdentity.cs
@@ -1,6 +1,7 @@
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
+using Yavsc.Attributes.Validation;
namespace Yavsc.Models.Bank
{
@@ -14,7 +15,7 @@ namespace Yavsc.Models.Bank
///
/// The BI.
[DisplayName("Code BIC")]
- [StringLength(15)]
+ [YaStringLength(15)]
public string BIC { get; set; }
///
@@ -22,7 +23,7 @@ namespace Yavsc.Models.Bank
///
/// The IBA.
[DisplayName("Code IBAN")]
- [StringLength(33)]
+ [YaStringLength(33)]
public string IBAN { get; set; }
@@ -31,7 +32,7 @@ namespace Yavsc.Models.Bank
///
/// The bank code.
[DisplayName("Code Banque")]
- [StringLength(5)]
+ [YaStringLength(5)]
public string BankCode { get; set; }
///
@@ -39,7 +40,7 @@ namespace Yavsc.Models.Bank
///
/// The wicket code.
[DisplayName("Code Guichet")]
- [StringLength(5)]
+ [YaStringLength(5)]
public string WicketCode { get; set; }
///
@@ -47,7 +48,7 @@ namespace Yavsc.Models.Bank
///
/// The account number.
[DisplayName("Numéro de compte")]
- [StringLength(15)]
+ [YaStringLength(15)]
public string AccountNumber { get; set; }
///
diff --git a/src/Yavsc.Server/Models/Blog/BlogPost.cs b/src/Yavsc.Server/Models/Blog/BlogPost.cs
index 30add0ff..c956a669 100644
--- a/src/Yavsc.Server/Models/Blog/BlogPost.cs
+++ b/src/Yavsc.Server/Models/Blog/BlogPost.cs
@@ -5,6 +5,7 @@ using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using Newtonsoft.Json;
using Yavsc.Abstract.Identity.Security;
+using Yavsc.Attributes.Validation;
using Yavsc.Interfaces;
using Yavsc.Models.Access;
using Yavsc.Models.Relationship;
@@ -17,19 +18,19 @@ namespace Yavsc.Models.Blog
[Display(Name="Identifiant du post")]
public long Id { get; set; }
- [Display(Name="Contenu")][StringLength(56224)]
+ [Display(Name="Contenu")][YaStringLength(56224)]
public string Content { get; set; }
- [Display(Name="Photo")][StringLength(1024)]
+ [Display(Name="Photo")][YaStringLength(1024)]
public string Photo { get; set; }
- [StringLength(8)]
+ [YaStringLength(8)]
public string Lang { get; set; }
[Display(Name="Indice de qualité")]
public int Rate { get; set; }
- [Display(Name="Titre")][StringLength(1024)]
+ [Display(Name="Titre")][YaStringLength(1024)]
public string Title { get; set; }
[Display(Name="Identifiant de l'auteur")]
diff --git a/src/Yavsc.Server/Models/Blog/Comment.cs b/src/Yavsc.Server/Models/Blog/Comment.cs
index 2a2553cb..07190459 100644
--- a/src/Yavsc.Server/Models/Blog/Comment.cs
+++ b/src/Yavsc.Server/Models/Blog/Comment.cs
@@ -13,7 +13,7 @@ namespace Yavsc.Models.Blog
[Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; }
- [StringLength(1024)]
+ [YaStringLength(1024)]
public string Content { get; set; }
[ForeignKeyAttribute("PostId")][JsonIgnore]
diff --git a/src/Yavsc.Server/Models/Chat/ChatRoom.cs b/src/Yavsc.Server/Models/Chat/ChatRoom.cs
index f0147f82..80d172ac 100644
--- a/src/Yavsc.Server/Models/Chat/ChatRoom.cs
+++ b/src/Yavsc.Server/Models/Chat/ChatRoom.cs
@@ -5,6 +5,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json;
using Yavsc.Abstract.Chat;
+using Yavsc.Attributes.Validation;
namespace Yavsc.Models.Chat
{
@@ -13,7 +14,7 @@ namespace Yavsc.Models.Chat
public string Topic { get; set; }
[Key]
- [StringLengthAttribute(ChatHubConstants.MaxChanelName, MinimumLength=3)]
+ [YaStringLength(ChatHubConstants.MaxChanelName, MinimumLength=3)]
public string Name { get; set;}
public string OwnerId { get; set; }
diff --git a/src/Yavsc.Server/Models/HairCut/HairCutQuery.cs b/src/Yavsc.Server/Models/HairCut/HairCutQuery.cs
index a47a21b9..f6ac6954 100644
--- a/src/Yavsc.Server/Models/HairCut/HairCutQuery.cs
+++ b/src/Yavsc.Server/Models/HairCut/HairCutQuery.cs
@@ -13,6 +13,7 @@ using Microsoft.Extensions.Localization;
using Yavsc.ViewModels.PayPal;
using Yavsc.Models.HairCut;
using Yavsc.Abstract.Identity;
+using Yavsc.Attributes.Validation;
namespace Yavsc.Models.Haircut
{
@@ -65,8 +66,7 @@ namespace Yavsc.Models.Haircut
set;
}
- [Display(Name = "Informations complémentaires"),
- StringLengthAttribute(512)]
+ [Display(Name = "Informations complémentaires"), YaStringLength(512)]
[DisplayFormat(ConvertEmptyStringToNull = true, NullDisplayText = "[pas d'informations complémentaires]")]
public string AdditionalInfo { get; set; }
diff --git a/src/Yavsc.Server/Models/IT/Evolution/Feature.cs b/src/Yavsc.Server/Models/IT/Evolution/Feature.cs
index 5bdcf7ed..3cfe452b 100644
--- a/src/Yavsc.Server/Models/IT/Evolution/Feature.cs
+++ b/src/Yavsc.Server/Models/IT/Evolution/Feature.cs
@@ -9,10 +9,10 @@ namespace Yavsc.Models.IT.Evolution
[Key,DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; }
- [StringLength(256)]
+ [YaStringLength(256)]
public string ShortName { get; set; }
- [StringLength(10*1024)]
+ [YaStringLength(10*1024)]
public string Description { get; set; }
public FeatureStatus Status { get; set; }
diff --git a/src/Yavsc.Server/Models/IT/Project.cs b/src/Yavsc.Server/Models/IT/Project.cs
index 47d81537..160ace97 100644
--- a/src/Yavsc.Server/Models/IT/Project.cs
+++ b/src/Yavsc.Server/Models/IT/Project.cs
@@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using Yavsc.Abstract.IT;
+using Yavsc.Attributes.Validation;
using Yavsc.Billing;
using Yavsc.Models.Billing;
using Yavsc.Server.Models.IT.SourceCode;
@@ -23,7 +24,7 @@ namespace Yavsc.Server.Models.IT
/// As a side effect, there's no project without valid git reference in db.
///
///
- [Required]
+ [YaRequired]
public string Name { get; set; }
public string Version { get; set; }
@@ -32,7 +33,7 @@ namespace Yavsc.Server.Models.IT
public virtual List Configurations { get; set; }
- [Required]
+ [YaRequired]
public long GitId { get; set; }
[ForeignKey("GitId")]
diff --git a/src/Yavsc.Server/Models/IT/ProjectBuildConfiguration.cs b/src/Yavsc.Server/Models/IT/ProjectBuildConfiguration.cs
index e2f96bed..7101ce80 100644
--- a/src/Yavsc.Server/Models/IT/ProjectBuildConfiguration.cs
+++ b/src/Yavsc.Server/Models/IT/ProjectBuildConfiguration.cs
@@ -1,5 +1,6 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
+using Yavsc.Attributes.Validation;
namespace Yavsc.Server.Models.IT
{
@@ -12,7 +13,7 @@ namespace Yavsc.Server.Models.IT
[Key,DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; }
- [Required]
+ [YaRequired]
public string Name { get; set; }
public long ProjectId { get; set; }
diff --git a/src/Yavsc.Server/Models/IT/SourceCode/GitRepository.cs b/src/Yavsc.Server/Models/IT/SourceCode/GitRepository.cs
index 11f6f577..26a81c1e 100644
--- a/src/Yavsc.Server/Models/IT/SourceCode/GitRepository.cs
+++ b/src/Yavsc.Server/Models/IT/SourceCode/GitRepository.cs
@@ -1,5 +1,6 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
+using Yavsc.Attributes.Validation;
using Yavsc.Models;
namespace Yavsc.Server.Models.IT.SourceCode
@@ -9,16 +10,16 @@ namespace Yavsc.Server.Models.IT.SourceCode
[Key,DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; }
- [Required]
+ [YaRequired]
public string Path { get; set; }
- [StringLength(2048)]
+ [YaStringLength(2048)]
public string Url { get; set; }
- [StringLength(512)]
+ [YaStringLength(512)]
public string Branch { get; set; }
- [StringLength(1024)]
+ [YaStringLength(1024)]
public string OwnerId { get; set; }
[ForeignKey("OwnerId")]
diff --git a/src/Yavsc.Server/Models/Messaging/CircleEvent.cs b/src/Yavsc.Server/Models/Messaging/CircleEvent.cs
index 0e1eeb50..9eb673e8 100644
--- a/src/Yavsc.Server/Models/Messaging/CircleEvent.cs
+++ b/src/Yavsc.Server/Models/Messaging/CircleEvent.cs
@@ -25,17 +25,18 @@ using System.ComponentModel.DataAnnotations;
namespace Yavsc.Models.Messaging
{
using Models.Relationship;
- ///
- /// Event pub.
- ///
- public class CircleEvent: BaseEvent
+ using Yavsc.Attributes.Validation;
+
+ ///
+ /// Event pub.
+ ///
+ public class CircleEvent: BaseEvent
{
///
/// Gets or sets the circles.
///
/// The circles.
- [Required(ErrorMessageResourceName="Circles"),
- Display(Name="Circles")]
+ [YaRequired, Display(Name="Circles")]
public virtual List Circles{ get; set; }
public override string CreateBody()
diff --git a/src/Yavsc.Server/Models/Messaging/DimissClicked.cs b/src/Yavsc.Server/Models/Messaging/DimissClicked.cs
index e8e54e97..814e18ab 100644
--- a/src/Yavsc.Server/Models/Messaging/DimissClicked.cs
+++ b/src/Yavsc.Server/Models/Messaging/DimissClicked.cs
@@ -1,17 +1,18 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
+using Yavsc.Attributes.Validation;
namespace Yavsc.Models.Messaging
{
public class DimissClicked
{
- [Required]
+ [YaRequired]
public string UserId { get; set; }
[ForeignKey("UserId")]
public virtual ApplicationUser User { get; set; }
- [Required]
+ [YaRequired]
public long NotificationId { get; set; }
[ForeignKey("NotificationId")]
diff --git a/src/Yavsc.Server/Models/Messaging/LiveFlow.cs b/src/Yavsc.Server/Models/Messaging/LiveFlow.cs
index 62c704e6..003a2c8a 100644
--- a/src/Yavsc.Server/Models/Messaging/LiveFlow.cs
+++ b/src/Yavsc.Server/Models/Messaging/LiveFlow.cs
@@ -2,6 +2,7 @@ using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Yavsc.Abstract.Streaming;
+using Yavsc.Attributes.Validation;
namespace Yavsc.Models.Streaming
{
@@ -18,29 +19,29 @@ namespace Yavsc.Models.Streaming
/// a title for this flow
///
///
- [StringLength(255)]
+ [YaStringLength(255)]
[Display(Name="TitleLabel", ResourceType=typeof(LiveFlow))]
public string Title { get; set; }
// a little description
- [StringLength(1023)]
+ [YaStringLength(1023)]
[Display(Name="PitchLabel", ResourceType=typeof(LiveFlow))]
public string Pitch { get; set; }
// The stream type
- [StringLength(127)]
+ [YaStringLength(127)]
[Display(Name="MediaTypeLabel", ResourceType=typeof(LiveFlow))]
public string MediaType { get; set; }
// A name where to save this stream, relative to user's files root
- [StringLength(255)]
+ [YaStringLength(255)]
[Display(Name="DifferedFileNameLabel", ResourceType=typeof(LiveFlow))]
public string DifferedFileName { get; set; }
[Display(Name="SequenceNumberLabel", ResourceType=typeof(LiveFlow))]
public int SequenceNumber { get; set; }
- [Required]
+ [YaRequired]
[Display(Name="OwnerIdLabel", ResourceType=typeof(LiveFlow))]
public string OwnerId {get; set; }
diff --git a/src/Yavsc.Server/Models/Musical/Instrument.cs b/src/Yavsc.Server/Models/Musical/Instrument.cs
index ae93c9c4..5c692b6d 100644
--- a/src/Yavsc.Server/Models/Musical/Instrument.cs
+++ b/src/Yavsc.Server/Models/Musical/Instrument.cs
@@ -1,5 +1,6 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
+using Yavsc.Attributes.Validation;
namespace Yavsc.Models.Musical
{
@@ -9,7 +10,7 @@ namespace Yavsc.Models.Musical
[Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id {get; set; }
- [MaxLength(255),Required]
+ [MaxLength(255), YaRequired]
public string Name { get ; set; }
}
}
\ No newline at end of file
diff --git a/src/Yavsc.Server/Models/Musical/InstrumentRating.cs b/src/Yavsc.Server/Models/Musical/InstrumentRating.cs
index 7aa3e4df..1a851ab2 100644
--- a/src/Yavsc.Server/Models/Musical/InstrumentRating.cs
+++ b/src/Yavsc.Server/Models/Musical/InstrumentRating.cs
@@ -1,5 +1,6 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
+using Yavsc.Attributes.Validation;
using Yavsc.Models.Workflow;
namespace Yavsc.Models.Musical
@@ -9,7 +10,7 @@ namespace Yavsc.Models.Musical
[Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id {get; set; }
- [Required]
+ [YaRequired]
public long InstrumentId { get; set; }
[ForeignKey("InstrumentId")]
diff --git a/src/Yavsc.Server/Models/Musical/MusicalPreference.cs b/src/Yavsc.Server/Models/Musical/MusicalPreference.cs
index 4cb3b924..4bcbf8c8 100644
--- a/src/Yavsc.Server/Models/Musical/MusicalPreference.cs
+++ b/src/Yavsc.Server/Models/Musical/MusicalPreference.cs
@@ -1,5 +1,6 @@
using System.ComponentModel.DataAnnotations;
+using Yavsc.Attributes.Validation;
namespace Yavsc.Models.Musical
{
@@ -15,7 +16,7 @@ namespace Yavsc.Models.Musical
public int Rate { get; set; }
- [Required]
+ [YaRequired]
public long TendencyId {get; set; }
}
diff --git a/src/Yavsc.Server/Models/Musical/MusicalTendency.cs b/src/Yavsc.Server/Models/Musical/MusicalTendency.cs
index aeb9e06e..e8a4d7af 100644
--- a/src/Yavsc.Server/Models/Musical/MusicalTendency.cs
+++ b/src/Yavsc.Server/Models/Musical/MusicalTendency.cs
@@ -1,19 +1,15 @@
-
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
-
+using Yavsc.Attributes.Validation;
namespace Yavsc.Models.Musical {
-
-
public class MusicalTendency {
-
[Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id {get; set; }
- [MaxLength(255),Required]
+ [MaxLength(255),YaRequired]
public string Name { get ; set; }
}
diff --git a/src/Yavsc.Server/Models/Payment/PaypalPayment.cs b/src/Yavsc.Server/Models/Payment/PaypalPayment.cs
index 4c716455..3a88db01 100644
--- a/src/Yavsc.Server/Models/Payment/PaypalPayment.cs
+++ b/src/Yavsc.Server/Models/Payment/PaypalPayment.cs
@@ -6,13 +6,14 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace Yavsc.Models.Payment {
using Yavsc;
using Relationship;
+ using Yavsc.Attributes.Validation;
public class PayPalPayment : IBaseTrackedEntity
{
- [Required,Key]
+ [YaRequired,Key]
public string CreationToken { get; set; }
- [Required]
+ [YaRequired]
public string ExecutorId { get; set; }
[ForeignKey("ExecutorId")]
public virtual ApplicationUser Executor { get; set; }
diff --git a/src/Yavsc.Server/Models/Relationship/Circle.cs b/src/Yavsc.Server/Models/Relationship/Circle.cs
index 44e6b855..b209d593 100644
--- a/src/Yavsc.Server/Models/Relationship/Circle.cs
+++ b/src/Yavsc.Server/Models/Relationship/Circle.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json;
+using Yavsc.Attributes.Validation;
namespace Yavsc.Models.Relationship
{
@@ -13,10 +14,10 @@ namespace Yavsc.Models.Relationship
public bool Public { get; set; }
- [Required]
+ [YaRequired]
public string Name { get; set; }
- [Required]
+ [YaRequired]
public string OwnerId { get; set; }
[ForeignKey("OwnerId"),JsonIgnore,NotMapped]
diff --git a/src/Yavsc.Server/Models/Relationship/CircleMember.cs b/src/Yavsc.Server/Models/Relationship/CircleMember.cs
index e83215c7..fa30eda6 100644
--- a/src/Yavsc.Server/Models/Relationship/CircleMember.cs
+++ b/src/Yavsc.Server/Models/Relationship/CircleMember.cs
@@ -1,6 +1,7 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
+using Yavsc.Attributes.Validation;
namespace Yavsc.Models.Relationship
{
@@ -8,13 +9,13 @@ namespace Yavsc.Models.Relationship
public partial class CircleMember
{
- [Required]
+ [YaRequired]
public long CircleId { get; set; }
[ForeignKey("CircleId")]
public virtual Circle Circle { get; set; }
- [Required]
+ [YaRequired]
public string MemberId { get; set; }
[ForeignKey("MemberId")]
diff --git a/src/Yavsc.Server/Models/Relationship/Contact.cs b/src/Yavsc.Server/Models/Relationship/Contact.cs
index c8236517..0c0f4ba6 100644
--- a/src/Yavsc.Server/Models/Relationship/Contact.cs
+++ b/src/Yavsc.Server/Models/Relationship/Contact.cs
@@ -1,15 +1,16 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json;
+using Yavsc.Attributes.Validation;
namespace Yavsc.Models.Relationship
{
public class Contact: IContact
{
- [Required()]
+ [YaRequired()]
public string UserId { get; set; }
- [Required()]
+ [YaRequired()]
public string OwnerId { get; set; }
public string Name { get; set; }
diff --git a/src/Yavsc.Server/Models/Relationship/Location.cs b/src/Yavsc.Server/Models/Relationship/Location.cs
index 29e8dd7d..0287368e 100644
--- a/src/Yavsc.Server/Models/Relationship/Location.cs
+++ b/src/Yavsc.Server/Models/Relationship/Location.cs
@@ -1,5 +1,6 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
+using Yavsc.Attributes.Validation;
namespace Yavsc.Models.Relationship
{
@@ -12,7 +13,7 @@ namespace Yavsc.Models.Relationship
///
/// The longitude.
///
- [Required(),Display(Name="Longitude")]
+ [YaRequired(),Display(Name="Longitude")]
[Range(-180, 360.0)]
public double Longitude { get; set; }
@@ -21,7 +22,7 @@ namespace Yavsc.Models.Relationship
///
/// The latitude.
///
- [Required(),Display(Name="Latitude")]
+ [YaRequired(),Display(Name="Latitude")]
[Range(-90, 90 )]
public double Latitude { get; set; }
@@ -30,7 +31,7 @@ namespace Yavsc.Models.Relationship
public class Location : Position, ILocation {
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; }
- [Required(),
+ [YaRequired(),
Display(Name="Address"),
MaxLength(512)]
public string Address { get; set; }
diff --git a/src/Yavsc.Server/Models/Relationship/Tag.cs b/src/Yavsc.Server/Models/Relationship/Tag.cs
index 9fd1907b..fecd912f 100644
--- a/src/Yavsc.Server/Models/Relationship/Tag.cs
+++ b/src/Yavsc.Server/Models/Relationship/Tag.cs
@@ -1,6 +1,7 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
+using Yavsc.Attributes.Validation;
namespace Yavsc.Models.Relationship
{
@@ -8,7 +9,7 @@ namespace Yavsc.Models.Relationship
{
[Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; }
- [Required()]
+ [YaRequired()]
public string Name { get; set; }
}
}
diff --git a/src/Yavsc.Server/Models/Workflow/Activity.cs b/src/Yavsc.Server/Models/Workflow/Activity.cs
index 5e4859f8..0bb20335 100644
--- a/src/Yavsc.Server/Models/Workflow/Activity.cs
+++ b/src/Yavsc.Server/Models/Workflow/Activity.cs
@@ -9,22 +9,23 @@ namespace Yavsc.Models.Workflow
{
using Yavsc.Models.Market;
using Yavsc;
+ using Yavsc.Attributes.Validation;
public class Activity : IBaseTrackedEntity, IActivity
{
- [StringLength(512), Required, Key]
+ [YaStringLength(512), YaRequired, Key]
[Display(Name = "Code")]
public string Code { get; set; }
///
///
///
///
- [StringLength(512), Required()]
+ [YaStringLength(512), YaRequired()]
[Display(Name = "Nom")]
public string Name { get; set; }
- [StringLength(512)]
+ [YaStringLength(512)]
[Display(Name = "Code du parent")]
public string ParentCode { get; set; }
diff --git a/src/Yavsc.Server/Models/Workflow/CommandForm.cs b/src/Yavsc.Server/Models/Workflow/CommandForm.cs
index ace25b96..1d1e73f0 100644
--- a/src/Yavsc.Server/Models/Workflow/CommandForm.cs
+++ b/src/Yavsc.Server/Models/Workflow/CommandForm.cs
@@ -5,6 +5,8 @@ using Newtonsoft.Json;
namespace Yavsc.Models.Workflow
{
using Yavsc;
+ using Yavsc.Attributes.Validation;
+
public class CommandForm : ICommandForm
{
[Key,DatabaseGenerated(DatabaseGeneratedOption.Identity)]
@@ -14,7 +16,7 @@ namespace Yavsc.Models.Workflow
public string Title { get; set; }
- [Required]
+ [YaRequired]
public string ActivityCode { get; set; }
[ForeignKey("ActivityCode"),JsonIgnore]
diff --git a/src/Yavsc.Server/Models/Workflow/PerformerProfile.cs b/src/Yavsc.Server/Models/Workflow/PerformerProfile.cs
index e696a77d..18e45634 100644
--- a/src/Yavsc.Server/Models/Workflow/PerformerProfile.cs
+++ b/src/Yavsc.Server/Models/Workflow/PerformerProfile.cs
@@ -7,6 +7,7 @@ namespace Yavsc.Models.Workflow
using System;
using Models.Relationship;
using Newtonsoft.Json;
+ using Yavsc.Attributes.Validation;
using Yavsc.Workflow;
public class PerformerProfile : IPerformerProfile {
@@ -20,13 +21,13 @@ namespace Yavsc.Models.Workflow
[Display(Name="Activity"), JsonIgnore]
public virtual List Activity { get; set; }
- [Required,StringLength(14),Display(Name="SIREN"),
+ [YaRequired,YaStringLength(14),Display(Name="SIREN"),
RegularExpression(@"^[0-9]{9,14}$", ErrorMessage = "Only numbers are allowed here")]
public string SIREN { get; set; }
public long OrganizationAddressId { get; set; }
- [Required,Display(Name="Organization address"),ForeignKey("OrganizationAddressId")]
+ [YaRequired,Display(Name="Organization address"),ForeignKey("OrganizationAddressId")]
public virtual Location OrganizationAddress { get; set; }
[Display(Name="Accept notifications on client query")]
diff --git a/src/Yavsc.Server/Models/Workflow/RendezVous.cs b/src/Yavsc.Server/Models/Workflow/RendezVous.cs
index 07e84f18..c88c6d84 100644
--- a/src/Yavsc.Server/Models/Workflow/RendezVous.cs
+++ b/src/Yavsc.Server/Models/Workflow/RendezVous.cs
@@ -6,6 +6,7 @@ using Yavsc.Models.Market;
namespace Yavsc.Models.Workflow
{
using Models.Relationship;
+ using Yavsc.Attributes.Validation;
///
/// A date, between two persons
@@ -17,21 +18,21 @@ namespace Yavsc.Models.Workflow
/// Event date
///
///
- [Required(),Display(Name="EventDate")]
+ [YaRequired(),Display(Name="EventDate")]
public DateTime EventDate { get; set; }
///
/// Location identifier
///
///
- [Required]
+ [YaRequired]
public long LocationId { get; set; }
///
/// A Location for this event
///
///
- [Required(ErrorMessage="SpecifyPlace"),Display(Name="Location"),ForeignKey("LocationId")]
+ [YaRequired(ErrorMessage="SpecifyPlace"),Display(Name="Location"),ForeignKey("LocationId")]
public Location Location { get; set; }
}
diff --git a/src/Yavsc.Server/Models/Workflow/UserActivity.cs b/src/Yavsc.Server/Models/Workflow/UserActivity.cs
index 7408c22e..c6216c1d 100644
--- a/src/Yavsc.Server/Models/Workflow/UserActivity.cs
+++ b/src/Yavsc.Server/Models/Workflow/UserActivity.cs
@@ -1,18 +1,19 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json;
+using Yavsc.Attributes.Validation;
namespace Yavsc.Models.Workflow
{
public class UserActivity
{
- [Required]
+ [YaRequired]
public string UserId { get; set; }
[ForeignKey("UserId")]
public virtual PerformerProfile User { get; set; }
- [Required]
+ [YaRequired]
public string DoesCode { get; set; }
[ForeignKey("DoesCode")]
diff --git a/src/Yavsc.Server/ViewModels/Account/ChangePasswordBindingModel.cs b/src/Yavsc.Server/ViewModels/Account/ChangePasswordBindingModel.cs
index e3d4cccb..c5965194 100644
--- a/src/Yavsc.Server/ViewModels/Account/ChangePasswordBindingModel.cs
+++ b/src/Yavsc.Server/ViewModels/Account/ChangePasswordBindingModel.cs
@@ -1,18 +1,19 @@
using System.ComponentModel.DataAnnotations;
+using Yavsc.Attributes.Validation;
namespace Yavsc.Models.Account {
public class ChangePasswordBindingModel {
- [Required]
+ [YaRequired]
[DataType(DataType.Password)]
public string OldPassword { get; set; }
- [Required]
+ [YaRequired]
[DataType(DataType.Password)]
public string NewPassword { get; set; }
}
public class SetPasswordBindingModel {
- [Required]
+ [YaRequired]
[DataType(DataType.Password)]
public string NewPassword { get; set; }
diff --git a/src/Yavsc.Server/ViewModels/Account/ExternalLoginConfirmationViewModel.cs b/src/Yavsc.Server/ViewModels/Account/ExternalLoginConfirmationViewModel.cs
index a9ab63df..a7717f52 100644
--- a/src/Yavsc.Server/ViewModels/Account/ExternalLoginConfirmationViewModel.cs
+++ b/src/Yavsc.Server/ViewModels/Account/ExternalLoginConfirmationViewModel.cs
@@ -6,12 +6,12 @@ namespace Yavsc.ViewModels.Account
{
public class ExternalLoginConfirmationViewModel
{
- [Required]
+ [YaRequired]
[YaStringLength(2,Constants.MaxUserNameLength)]
[YaRegularExpression(Constants.UserNameRegExp)]
public string Name { get; set; }
- [Required]
+ [YaRequired]
[EmailAddress]
public string Email { get; set; }
diff --git a/src/Yavsc.Server/ViewModels/Account/ForgotPasswordViewModel.cs b/src/Yavsc.Server/ViewModels/Account/ForgotPasswordViewModel.cs
index c21b5507..623179d8 100644
--- a/src/Yavsc.Server/ViewModels/Account/ForgotPasswordViewModel.cs
+++ b/src/Yavsc.Server/ViewModels/Account/ForgotPasswordViewModel.cs
@@ -1,12 +1,13 @@
using System.ComponentModel.DataAnnotations;
+using Yavsc.Attributes.Validation;
namespace Yavsc.ViewModels.Account
{
public class ForgotPasswordViewModel
{
- [Required]
- [StringLength(512)]
+ [YaRequired]
+ [YaStringLength(512)]
public string LoginOrEmail { get; set; }
}
}
diff --git a/src/Yavsc.Server/ViewModels/Account/LoginViewModel.cs b/src/Yavsc.Server/ViewModels/Account/LoginViewModel.cs
index ef0c56d0..59b7ac42 100755
--- a/src/Yavsc.Server/ViewModels/Account/LoginViewModel.cs
+++ b/src/Yavsc.Server/ViewModels/Account/LoginViewModel.cs
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
+using Yavsc.Attributes.Validation;
namespace Yavsc.ViewModels.Account
{
@@ -10,14 +11,14 @@ namespace Yavsc.ViewModels.Account
/// Local user's name.
///
///
- [Required]
+ [YaRequired]
public string UserName { get; set; }
///
/// Local user's password .
///
///
- [Required]
+ [YaRequired]
[DataType(DataType.Password)]
public string Password { get; set; }
diff --git a/src/Yavsc.Server/ViewModels/Account/RegisterViewModel.cs b/src/Yavsc.Server/ViewModels/Account/RegisterViewModel.cs
index 432e2b73..5f6f3d5d 100644
--- a/src/Yavsc.Server/ViewModels/Account/RegisterViewModel.cs
+++ b/src/Yavsc.Server/ViewModels/Account/RegisterViewModel.cs
@@ -11,7 +11,7 @@ namespace Yavsc.ViewModels.Account
[YaRegularExpression(Constants.UserNameRegExp)]
public string UserName { get; set; }
- [Required()]
+ [YaRequired()]
[YaStringLength(2,102)]
// [EmailAddress]
[Display(Name = "Email")]
diff --git a/src/Yavsc.Server/ViewModels/Account/ResetPasswordViewModel.cs b/src/Yavsc.Server/ViewModels/Account/ResetPasswordViewModel.cs
index 0eac7dac..6352b3f9 100644
--- a/src/Yavsc.Server/ViewModels/Account/ResetPasswordViewModel.cs
+++ b/src/Yavsc.Server/ViewModels/Account/ResetPasswordViewModel.cs
@@ -1,15 +1,16 @@
using System.ComponentModel.DataAnnotations;
+using Yavsc.Attributes.Validation;
namespace Yavsc.ViewModels.Account
{
public class ResetPasswordViewModel
{
- [Required]
+ [YaRequired]
[EmailAddress]
public string Email { get; set; }
- [Required]
- [StringLength(100, ErrorMessage = "Le {0} doit être long d'au moins {2} caractères.", MinimumLength = 6)]
+ [YaRequired]
+ [YaStringLength(100, ErrorMessage = "Le {0} doit être long d'au moins {2} caractères.", MinimumLength = 6)]
[DataType(DataType.Password)]
public string Password { get; set; }
diff --git a/src/Yavsc.Server/ViewModels/Account/UnregisterViewModel.cs b/src/Yavsc.Server/ViewModels/Account/UnregisterViewModel.cs
index b672e8bb..728cf7d1 100644
--- a/src/Yavsc.Server/ViewModels/Account/UnregisterViewModel.cs
+++ b/src/Yavsc.Server/ViewModels/Account/UnregisterViewModel.cs
@@ -1,10 +1,11 @@
using System.ComponentModel.DataAnnotations;
+using Yavsc.Attributes.Validation;
namespace Yavsc.ViewModels.Account
{
public class UnregisterViewModel
{
- [Required]
+ [YaRequired]
public string UserId { get; set; }
public string ReturnUrl { get; set; }
diff --git a/src/Yavsc.Server/ViewModels/Account/VerifyCodeViewModel.cs b/src/Yavsc.Server/ViewModels/Account/VerifyCodeViewModel.cs
index 9dcf5854..223f6e8f 100644
--- a/src/Yavsc.Server/ViewModels/Account/VerifyCodeViewModel.cs
+++ b/src/Yavsc.Server/ViewModels/Account/VerifyCodeViewModel.cs
@@ -1,13 +1,14 @@
using System.ComponentModel.DataAnnotations;
+using Yavsc.Attributes.Validation;
namespace Yavsc.ViewModels.Account
{
public class VerifyCodeViewModel
{
- [Required]
+ [YaRequired]
public string Provider { get; set; }
- [Required]
+ [YaRequired]
public string Code { get; set; }
public string ReturnUrl { get; set; }
diff --git a/src/Yavsc.Server/ViewModels/Manage/AddPhoneNumberViewModel.cs b/src/Yavsc.Server/ViewModels/Manage/AddPhoneNumberViewModel.cs
index bc823f50..143d6ea0 100644
--- a/src/Yavsc.Server/ViewModels/Manage/AddPhoneNumberViewModel.cs
+++ b/src/Yavsc.Server/ViewModels/Manage/AddPhoneNumberViewModel.cs
@@ -1,10 +1,11 @@
using System.ComponentModel.DataAnnotations;
+using Yavsc.Attributes.Validation;
namespace Yavsc.ViewModels.Manage
{
public class AddPhoneNumberViewModel
{
- [Required]
+ [YaRequired]
[Phone]
[Display(Name = "Phone number")]
public string PhoneNumber { get; set; }
diff --git a/src/Yavsc.Server/ViewModels/Manage/ChangePasswordViewModel.cs b/src/Yavsc.Server/ViewModels/Manage/ChangePasswordViewModel.cs
index 5bcdc382..37f1f558 100644
--- a/src/Yavsc.Server/ViewModels/Manage/ChangePasswordViewModel.cs
+++ b/src/Yavsc.Server/ViewModels/Manage/ChangePasswordViewModel.cs
@@ -1,16 +1,17 @@
using System.ComponentModel.DataAnnotations;
+using Yavsc.Attributes.Validation;
namespace Yavsc.ViewModels.Manage
{
public class ChangePasswordViewModel
{
- [Required]
+ [YaRequired]
[DataType(DataType.Password)]
[Display(Name = "Current password")]
public string OldPassword { get; set; }
- [Required]
- [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
+ [YaRequired]
+ [YaStringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "New password")]
public string NewPassword { get; set; }
diff --git a/src/Yavsc.Server/ViewModels/Manage/DoDirectCreditViewModel.cs b/src/Yavsc.Server/ViewModels/Manage/DoDirectCreditViewModel.cs
index 7ee28f2c..bfeccd24 100644
--- a/src/Yavsc.Server/ViewModels/Manage/DoDirectCreditViewModel.cs
+++ b/src/Yavsc.Server/ViewModels/Manage/DoDirectCreditViewModel.cs
@@ -1,35 +1,36 @@
using System.ComponentModel.DataAnnotations;
+using Yavsc.Attributes.Validation;
namespace Yavsc.ViewModels.Manage
{
public class DoDirectCreditViewModel {
- [Required]
+ [YaRequired]
public string PaymentType { get; set;}
- [Required]
+ [YaRequired]
public string PayerName { get; set;}
- [Required]
+ [YaRequired]
public string FirstName { get; set;}
- [Required]
+ [YaRequired]
public string LastName { get; set;}
- [Required]
+ [YaRequired]
public string CreditCardNumber { get; set;}
public string CreditCardType { get; set;}
public string Cvv2Number { get; set;}
public string CardExpiryDate { get; set;}
public string IpnNotificationUrl { get; set; }
- [Required]
+ [YaRequired]
public string Street1 { get; set; }
public string Street2 { get; set; }
public string City { get; set; }
public string State { get; set; }
public string Country { get; set; }
- [Required]
+ [YaRequired]
public string PostalCode { get; set; }
public string Phone { get; set; }
- [Required]
+ [YaRequired]
public string CurrencyCode { get; set; }
- [Required]
+ [YaRequired]
public string Amount { get; set; }
}
}
diff --git a/src/Yavsc.Server/ViewModels/Manage/SetAddressViewModel.cs b/src/Yavsc.Server/ViewModels/Manage/SetAddressViewModel.cs
index b7998761..c1ec9131 100644
--- a/src/Yavsc.Server/ViewModels/Manage/SetAddressViewModel.cs
+++ b/src/Yavsc.Server/ViewModels/Manage/SetAddressViewModel.cs
@@ -1,16 +1,17 @@
using System.ComponentModel.DataAnnotations;
+using Yavsc.Attributes.Validation;
namespace Yavsc.ViewModels.Manage
{
public class SetAddressViewModel
{
- [Required]
+ [YaRequired]
public string Street1 { get; set; }
public string Street2 { get; set; }
public string City { get; set; }
public string State { get; set; }
public string Country { get; set; }
- [Required]
+ [YaRequired]
public string PostalCode { get; set; }
}
}
diff --git a/src/Yavsc.Server/ViewModels/Manage/SetPasswordViewModel.cs b/src/Yavsc.Server/ViewModels/Manage/SetPasswordViewModel.cs
index b751871b..0a948674 100644
--- a/src/Yavsc.Server/ViewModels/Manage/SetPasswordViewModel.cs
+++ b/src/Yavsc.Server/ViewModels/Manage/SetPasswordViewModel.cs
@@ -1,11 +1,12 @@
using System.ComponentModel.DataAnnotations;
+using Yavsc.Attributes.Validation;
namespace Yavsc.ViewModels.Manage
{
public class SetPasswordViewModel
{
- [Required]
- [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
+ [YaRequired]
+ [YaStringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "New password")]
public string NewPassword { get; set; }
diff --git a/src/Yavsc.Server/ViewModels/Manage/VerifyPhoneNumberViewModel.cs b/src/Yavsc.Server/ViewModels/Manage/VerifyPhoneNumberViewModel.cs
index 71e87280..1430f853 100644
--- a/src/Yavsc.Server/ViewModels/Manage/VerifyPhoneNumberViewModel.cs
+++ b/src/Yavsc.Server/ViewModels/Manage/VerifyPhoneNumberViewModel.cs
@@ -1,13 +1,14 @@
using System.ComponentModel.DataAnnotations;
+using Yavsc.Attributes.Validation;
namespace Yavsc.ViewModels.Manage
{
public class VerifyPhoneNumberViewModel
{
- [Required]
+ [YaRequired]
public string Code { get; set; }
- [Required]
+ [YaRequired]
[Phone]
[Display(Name = "Phone number")]
public string PhoneNumber { get; set; }
diff --git a/src/Yavsc/ApiControllers/Blogspot/FileSystemApiController.cs b/src/Yavsc/ApiControllers/Blogspot/FileSystemApiController.cs
index 036af5a8..bdc421cb 100644
--- a/src/Yavsc/ApiControllers/Blogspot/FileSystemApiController.cs
+++ b/src/Yavsc/ApiControllers/Blogspot/FileSystemApiController.cs
@@ -13,10 +13,7 @@ namespace Yavsc.ApiControllers
using Yavsc.Helpers;
using Yavsc.Exceptions;
using Yavsc.Models.FileSystem;
-
- public class FSQuotaException : Exception {
-
- }
+ using System.ComponentModel.DataAnnotations;
[Authorize,Route("api/fs")]
public class FileSystemApiController : Controller
@@ -55,6 +52,7 @@ namespace Yavsc.ApiControllers
[HttpPost("{*subdir}")]
public IActionResult Post(string subdir="")
{
+
string destDir = null;
List received = new List();
InvalidPathException pathex = null;
@@ -89,7 +87,7 @@ namespace Yavsc.ApiControllers
return Ok(received);
}
- [Route("/api/fsquota/add/{uname}/{len}")]
+ [Route("/api/fsc/addquota/{uname}/{len}")]
[Authorize("AdministratorOnly")]
public IActionResult AddQuota(string uname, int len)
{
@@ -102,7 +100,7 @@ namespace Yavsc.ApiControllers
return Ok(len);
}
- [Route("/api/movefile")]
+ [Route("/api/fsc/movefile")]
[Authorize()]
public IActionResult MoveFile(string from, string to)
{
@@ -110,11 +108,14 @@ namespace Yavsc.ApiControllers
var user = dbContext.Users.Single(
u => u.Id == uid
);
- throw new NotImplementedException();
+ var info = user.MoveUserFile(from, to);
+ if (!info.Done)
+ return new BadRequestObjectResult(info);
return Ok();
}
- [Route("/api/movedir")]
+ [HttpPatch]
+ [Route("/api/fsc/movedir")]
[Authorize()]
public IActionResult MoveDir(string from, string to)
{
@@ -122,29 +123,67 @@ namespace Yavsc.ApiControllers
var user = dbContext.Users.Single(
u => u.Id == uid
);
- throw new NotImplementedException();
+ try {
+ var result = user.MoveUserDir(from, to);
+ if (!result.Done)
+ return new BadRequestObjectResult(result);
+ }
+ catch (Exception ex)
+ {
+ return new BadRequestObjectResult(
+ new FsOperationInfo {
+ Done = false,
+ Error = ex.Message
+ });
+ }
return Ok();
}
[HttpDelete]
+ [Route("/api/fsc/rm/{*id}")]
public async Task Delete (string id)
{
var user = dbContext.Users.Single(
u => u.Id == User.GetUserId()
);
- InvalidPathException pathex = null;
- string root = null;
try {
- root = User.InitPostToFileSystem(id);
- } catch (InvalidPathException ex) {
- pathex = ex;
- }
- if (pathex!=null)
- return new BadRequestObjectResult(pathex);
user.DeleteUserFile(id);
await dbContext.SaveChangesAsync(User.GetUserId());
- return Ok(new { deleted=id });
+ }
+ catch (Exception ex)
+ {
+ return new BadRequestObjectResult(
+ new FsOperationInfo {
+ Done = false,
+ Error = ex.Message
+ });
+ }
+ return Ok(new { deleted=id });
+ }
+
+ [HttpDelete]
+ [Route("/api/fsc/rmdir/{*id}")]
+ public IActionResult RemoveDir (string id)
+ {
+ var user = dbContext.Users.Single(
+ u => u.Id == User.GetUserId()
+ );
+ try {
+ var result = user.DeleteUserDir(id);
+ if (!result.Done)
+ return new BadRequestObjectResult(result);
+ }
+ catch (Exception ex)
+ {
+ return new BadRequestObjectResult(
+ new FsOperationInfo {
+ Done = false,
+ Error = ex.Message
+ });
+ }
+ return Ok(new { deleted=id });
}
}
+
}
diff --git a/src/Yavsc/ApiControllers/Blogspot/TestApiController.cs b/src/Yavsc/ApiControllers/Blogspot/TestApiController.cs
new file mode 100644
index 00000000..c21783ad
--- /dev/null
+++ b/src/Yavsc/ApiControllers/Blogspot/TestApiController.cs
@@ -0,0 +1,15 @@
+using Microsoft.AspNet.Authorization;
+using Microsoft.AspNet.Mvc;
+
+namespace Yavsc.ApiControllers
+{
+ using System.ComponentModel.DataAnnotations;
+ using Yavsc.Attributes.Validation;
+
+ [Authorize,Route("~/api/test")]
+ public class TestApiController : Controller
+ {
+
+ }
+
+}
diff --git a/src/Yavsc/Helpers/FileSystemHelpers.cs b/src/Yavsc/Helpers/FileSystemHelpers.cs
index d032ead6..c78a6312 100644
--- a/src/Yavsc/Helpers/FileSystemHelpers.cs
+++ b/src/Yavsc/Helpers/FileSystemHelpers.cs
@@ -7,6 +7,7 @@ using System.IO;
using System.Security.Claims;
using System.Threading;
using System.Web;
+using Microsoft.AspNet.FileProviders;
using Microsoft.AspNet.Http;
using Yavsc.Exceptions;
using Yavsc.Models;
@@ -102,6 +103,58 @@ namespace Yavsc.Helpers
fi.Delete();
user.DiskUsage -= fi.Length;
}
+
+ public static FsOperationInfo DeleteUserDir(this ApplicationUser user, string dirName)
+ {
+ var root = Path.Combine(AbstractFileSystemHelpers.UserFilesDirName, user.UserName);
+ if (string.IsNullOrEmpty(dirName))
+ return new FsOperationInfo { Done = false, Error = "specify a dir name"} ;
+
+ var di = new DirectoryInfo(Path.Combine(root, dirName));
+ if (!di.Exists) return new FsOperationInfo { Done = false, Error = "non existent"} ;
+ if (di.GetDirectories().Length>0 || di.GetFiles().Length>0)
+ return new FsOperationInfo { Done = false, Error = "not eñpty"} ;
+ di.Delete();
+ return new FsOperationInfo { Done = true };
+ }
+
+ public static FsOperationInfo MoveUserDir(this ApplicationUser user, string fromDirName, string toDirName)
+ {
+ var root = Path.Combine(AbstractFileSystemHelpers.UserFilesDirName, user.UserName);
+ if (string.IsNullOrEmpty(fromDirName))
+ return new FsOperationInfo { Done = false, Error = "fromDirName: specify a dir name "} ;
+
+ var di = new DirectoryInfo(Path.Combine(root, fromDirName));
+ if (!di.Exists) return new FsOperationInfo { Done = false, Error = "fromDirName: non existent"} ;
+
+
+ if (string.IsNullOrEmpty(toDirName))
+ return new FsOperationInfo { Done = false, Error = "toDirName: specify a dir name to move"} ;
+
+ var destPath = Path.Combine(root, toDirName);
+
+ var fo = new FileInfo(destPath);
+ var dout = new DirectoryInfo(destPath);
+
+ if (fo.Exists) return new FsOperationInfo { Done = false, Error = "toDirName: yet a regular file" } ;
+
+
+ if (dout.Exists) {
+ destPath = Path.Combine(destPath, fo.Name);
+ }
+ di.MoveTo(destPath);
+ return new FsOperationInfo { Done = true };
+ }
+ public static FsOperationInfo MoveUserFile(this ApplicationUser user, string fileNameFrom, string fileNameDest)
+ {
+ var root = Path.Combine(AbstractFileSystemHelpers.UserFilesDirName, user.UserName);
+ var fi = new FileInfo(Path.Combine(root, fileNameFrom));
+ if (!fi.Exists) return new FsOperationInfo { Error = "no file to move" } ;
+ var fo = new FileInfo(Path.Combine(root, fileNameDest));
+ if (fo.Exists) return new FsOperationInfo { Error = "destination file name is an existing file" } ;
+ fi.MoveTo(fo.FullName);
+ return new FsOperationInfo { Done = true };
+ }
static string ParseFileNameFromDisposition(string disposition)
{
@@ -167,6 +220,15 @@ namespace Yavsc.Helpers
return new HtmlString(
$"{Startup.UserFilesOptions.RequestPath}/{username}/{subpath}/{info.Name}" );
}
+
+ public static RemoteFileInfo FileInfo(this ApplicationUser user, string path)
+ {
+ IFileInfo info = Startup.UserFilesOptions.FileProvider.GetFileInfo($"{user.UserName}/{path}");
+ if (!info.Exists) return null;
+ return new RemoteFileInfo{ Name = info.Name, Size = info.Length, LastModified = info.LastModified.UtcDateTime };
+
+ }
+
public static FileRecievedInfo ReceiveAvatar(this ApplicationUser user, IFormFile formFile)
{
var item = new FileRecievedInfo();
diff --git a/src/Yavsc/ViewModels/Administration/EnrolerViewModel.cs b/src/Yavsc/ViewModels/Administration/EnrolerViewModel.cs
index e7ed84e9..bf19fc38 100644
--- a/src/Yavsc/ViewModels/Administration/EnrolerViewModel.cs
+++ b/src/Yavsc/ViewModels/Administration/EnrolerViewModel.cs
@@ -1,16 +1,17 @@
using System.ComponentModel.DataAnnotations;
+using Yavsc.Attributes.Validation;
namespace Yavsc.ViewModels
{
public partial class EnrolerViewModel {
[Display(Name="EnroledLabel", ResourceType=typeof(EnrolerViewModel))]
- [Required]
+ [YaRequired]
public string EnroledUserId { get; set; }
[Display(Name="RoleNameLabel", ResourceType=typeof(EnrolerViewModel))]
- [Required]
+ [YaRequired]
public string RoleName { get; set; }
}
}
\ No newline at end of file
diff --git a/src/Yavsc/ViewModels/Administration/FireViewModel.cs b/src/Yavsc/ViewModels/Administration/FireViewModel.cs
index bd6df3e4..bcbfefad 100644
--- a/src/Yavsc/ViewModels/Administration/FireViewModel.cs
+++ b/src/Yavsc/ViewModels/Administration/FireViewModel.cs
@@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations;
+using Yavsc.Attributes.Validation;
namespace Yavsc.ViewModels
{
@@ -7,12 +8,12 @@ namespace Yavsc.ViewModels
[Display(Name="EnroledLabel", ResourceType=typeof(EnrolerViewModel))]
public string EnroledUserName { get; set; }
- [Required]
+ [YaRequired]
public string EnroledUserId { get; set; }
[Display(Name="RoleNameLabel", ResourceType=typeof(EnrolerViewModel))]
- [Required]
+ [YaRequired]
public string RoleName { get; set; }
}
}
\ No newline at end of file
diff --git a/src/Yavsc/ViewModels/Gen/PdfGenerationViewModel.cs b/src/Yavsc/ViewModels/Gen/PdfGenerationViewModel.cs
index 53808880..0e0cc0e3 100644
--- a/src/Yavsc/ViewModels/Gen/PdfGenerationViewModel.cs
+++ b/src/Yavsc/ViewModels/Gen/PdfGenerationViewModel.cs
@@ -1,16 +1,17 @@
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNet.Mvc.Rendering;
+using Yavsc.Attributes.Validation;
namespace Yavsc.ViewModels.Gen
{
public class PdfGenerationViewModel
{
- [Required]
+ [YaRequired]
public string TeXSource { get; set; }
- [Required]
+ [YaRequired]
public string BaseFileName { get; set; }
- [Required]
+ [YaRequired]
public string DestDir { get; set; }
public bool Generated { get; set; }
public HtmlString GenerationErrorMessage { get; set; }
diff --git a/src/Yavsc/ViewModels/Manage/ChangeUserNameViewModel.cs b/src/Yavsc/ViewModels/Manage/ChangeUserNameViewModel.cs
index d5d1d9f1..8299c727 100644
--- a/src/Yavsc/ViewModels/Manage/ChangeUserNameViewModel.cs
+++ b/src/Yavsc/ViewModels/Manage/ChangeUserNameViewModel.cs
@@ -1,11 +1,12 @@
using System.ComponentModel.DataAnnotations;
+using Yavsc.Attributes.Validation;
namespace Yavsc.ViewModels.Manage
{
public class ChangeUserNameViewModel
{
- [Required]
+ [YaRequired]
[Display(Name = "New user name"),RegularExpression(Constants.UserNameRegExp)]
public string NewUserName { get; set; }
diff --git a/src/Yavsc/ViewModels/Manage/SetFullNameViewModel.cs b/src/Yavsc/ViewModels/Manage/SetFullNameViewModel.cs
index ea99a476..3bef37f5 100644
--- a/src/Yavsc/ViewModels/Manage/SetFullNameViewModel.cs
+++ b/src/Yavsc/ViewModels/Manage/SetFullNameViewModel.cs
@@ -6,7 +6,7 @@ namespace Yavsc.ViewModels.Manage
{
public class SetFullNameViewModel
{
- [Required]
+ [YaRequired]
[Display(Name = "Your full name"), YaStringLength(512)]
public string FullName { get; set; }
}
diff --git a/src/cli/Commands/GenerateJsonSchema.cs b/src/cli/Commands/GenerateJsonSchema.cs
index ad9ad38b..e54e4918 100644
--- a/src/cli/Commands/GenerateJsonSchema.cs
+++ b/src/cli/Commands/GenerateJsonSchema.cs
@@ -3,6 +3,7 @@ using System.Threading.Tasks;
using NJsonSchema;
using System.IO;
using cli.Model;
+using Yavsc.Abstract.IT;
namespace cli
{