Using YaStringLength and YaRequired

vnext
Paul Schneider 5 years ago
parent 8a2f87bcb2
commit 65d6fdc6c6
62 changed files with 396 additions and 150 deletions

@ -14,10 +14,12 @@ namespace Yavsc.Attributes.Validation
{ {
ErrorMessage = msg; 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) { public override bool IsValid(object value) {
if (value == null) { if (value == null) {
return false; return false;

@ -20,7 +20,7 @@ namespace Yavsc.Attributes.Validation
void UseDefaultErrorMessage() void UseDefaultErrorMessage()
{ {
if (ErrorMessageResourceType==null) { if (ErrorMessageResourceType==null) {
ErrorMessageResourceType = typeof(YaStringLength); ErrorMessageResourceType = typeof(Yavsc.Attributes.Validation.Resources);
ErrorMessageResourceName = "InvalidStringLength"; ErrorMessageResourceName = "InvalidStringLength";
} }
} }

@ -12,14 +12,24 @@ namespace Yavsc.Helpers
public static string UserBillsDirName { set; get; } public static string UserBillsDirName { set; get; }
public static string UserFilesDirName { set; get; } public static string UserFilesDirName { set; get; }
/// <summary>
/// Is Valid this Path?
/// Return true when given value is a valid user file sub-path,
/// regarding chars used to specify it.
/// </summary>
/// <param name="path">Path to validate</param>
/// <returns></returns>
public static bool IsValidYavscPath(this string path) public static bool IsValidYavscPath(this string path)
{ {
if (string.IsNullOrEmpty(path)) return true; 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)) foreach (var name in path.Split(Path.DirectorySeparatorChar))
{ {
if (!IsValidDirectoryName(name) || name.Equals("..") || name.Equals(".")) if (!IsValidDirectoryName(name) || name.Equals("..") || name.Equals("."))
return false; return false;
} }
// disallow trailling slash
if (path[path.Length-1]==RemoteDirectorySeparator) return false; if (path[path.Length-1]==RemoteDirectorySeparator) return false;
return true; return true;
} }

@ -0,0 +1,7 @@
namespace Yavsc.Helpers
{
public class FsOperationInfo {
public bool Done { get; set; } = false;
public string Error { get; set; }
}
}

@ -1,4 +1,4 @@
using System; using System;
namespace Yavsc.ViewModels namespace Yavsc.ViewModels
{ {
@ -12,7 +12,6 @@ namespace Yavsc.ViewModels
public DateTime LastModified { get; set; } public DateTime LastModified { get; set; }
} }
} }

@ -1,11 +1,12 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Yavsc.Attributes.Validation;
namespace Yavsc.Models.Identity namespace Yavsc.Models.Identity
{ {
public class BlackListedUserName : IWatchedUserName { public class BlackListedUserName : IWatchedUserName {
[Key] [Key]
[StringLength(1024)] [YaStringLength(1024)]
public string Name { get; set;} public string Name { get; set;}
} }

@ -1,11 +1,12 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Yavsc.Attributes.Validation;
namespace Yavsc.Models.Identity namespace Yavsc.Models.Identity
{ {
public class ReservedUserName : IWatchedUserName { public class ReservedUserName : IWatchedUserName {
[Key] [Key]
[StringLength(1024)] [YaStringLength(1024)]
public string Name { get; set;} public string Name { get; set;}
} }

@ -1,6 +1,6 @@
SOURCE_DIR=$(HOME)/workspace/yavsc SOURCE_DIR=$(HOME)/workspace/yavsc
MAKEFILE_DIR=$(SOURCE_DIR)/scripts/build/make 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) BASERESXGEN=$(BASERESX:.resx=.Designer.cs)
include $(MAKEFILE_DIR)/versioning.mk include $(MAKEFILE_DIR)/versioning.mk
include $(MAKEFILE_DIR)/dnx.mk include $(MAKEFILE_DIR)/dnx.mk

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<!--
route name for the api controller used to tag the 'BlogPost' entity
-->
<data name="FieldRequired"><value>Por favor, preencha este campo</value></data>
<data name="InvalidStringLength"><value>comprimento inválido da corrente ({0}..{1})</value></data>
</root>

@ -1,12 +1,12 @@
//------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// <auto-generated> // <autogenerated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.42000 // Mono Runtime Version: 4.0.30319.42000
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.
// </auto-generated> // </autogenerated>
//------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
namespace Yavsc.Attributes.Validation { namespace Yavsc.Attributes.Validation {
using System; using System;
@ -16,7 +16,7 @@ namespace Yavsc.Attributes.Validation {
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[System.Diagnostics.DebuggerNonUserCodeAttribute()] [System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
public partial class YaStringLength { public partial class Resources {
private static System.Resources.ResourceManager resourceMan; private static System.Resources.ResourceManager resourceMan;
@ -26,7 +26,7 @@ namespace Yavsc.Attributes.Validation {
public static System.Resources.ResourceManager ResourceManager { public static System.Resources.ResourceManager ResourceManager {
get { get {
if (object.Equals(null, resourceMan)) { 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; resourceMan = temp;
} }
return resourceMan; return resourceMan;
@ -43,6 +43,12 @@ namespace Yavsc.Attributes.Validation {
} }
} }
public static string FieldRequired {
get {
return ResourceManager.GetString("FieldRequired", resourceCulture);
}
}
public static string InvalidStringLength { public static string InvalidStringLength {
get { get {
return ResourceManager.GetString("InvalidStringLength", resourceCulture); return ResourceManager.GetString("InvalidStringLength", resourceCulture);

@ -61,6 +61,6 @@
<!-- <!--
route name for the api controller used to tag the 'BlogPost' entity route name for the api controller used to tag the 'BlogPost' entity
--> -->
<data name="FieldRequired"><value>Please, fill in this field</value></data>
<data name="InvalidStringLength"><value>Invalid string length ({0}..{1})</value></data> <data name="InvalidStringLength"><value>Invalid string length ({0}..{1})</value></data>
</root> </root>

@ -61,6 +61,6 @@
<!-- <!--
route name for the api controller used to tag the 'BlogPost' entity route name for the api controller used to tag the 'BlogPost' entity
--> -->
<data name="FieldRequired"><value>Veuillez renseigner ce champ</value></data>
<data name="InvalidStringLength"><value>Longueur de chaine invalide ({0}..{1})</value></data> <data name="InvalidStringLength"><value>Longueur de chaine invalide ({0}..{1})</value></data>
</root> </root>

@ -1,6 +1,7 @@
using System.ComponentModel; using System.ComponentModel;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Yavsc.Attributes.Validation;
namespace Yavsc.Models.Bank namespace Yavsc.Models.Bank
{ {
@ -14,7 +15,7 @@ namespace Yavsc.Models.Bank
/// </summary> /// </summary>
/// <value>The BI.</value> /// <value>The BI.</value>
[DisplayName("Code BIC")] [DisplayName("Code BIC")]
[StringLength(15)] [YaStringLength(15)]
public string BIC { get; set; } public string BIC { get; set; }
/// <summary> /// <summary>
@ -22,7 +23,7 @@ namespace Yavsc.Models.Bank
/// </summary> /// </summary>
/// <value>The IBA.</value> /// <value>The IBA.</value>
[DisplayName("Code IBAN")] [DisplayName("Code IBAN")]
[StringLength(33)] [YaStringLength(33)]
public string IBAN { get; set; } public string IBAN { get; set; }
@ -31,7 +32,7 @@ namespace Yavsc.Models.Bank
/// </summary> /// </summary>
/// <value>The bank code.</value> /// <value>The bank code.</value>
[DisplayName("Code Banque")] [DisplayName("Code Banque")]
[StringLength(5)] [YaStringLength(5)]
public string BankCode { get; set; } public string BankCode { get; set; }
/// <summary> /// <summary>
@ -39,7 +40,7 @@ namespace Yavsc.Models.Bank
/// </summary> /// </summary>
/// <value>The wicket code.</value> /// <value>The wicket code.</value>
[DisplayName("Code Guichet")] [DisplayName("Code Guichet")]
[StringLength(5)] [YaStringLength(5)]
public string WicketCode { get; set; } public string WicketCode { get; set; }
/// <summary> /// <summary>
@ -47,7 +48,7 @@ namespace Yavsc.Models.Bank
/// </summary> /// </summary>
/// <value>The account number.</value> /// <value>The account number.</value>
[DisplayName("Numéro de compte")] [DisplayName("Numéro de compte")]
[StringLength(15)] [YaStringLength(15)]
public string AccountNumber { get; set; } public string AccountNumber { get; set; }
/// <summary> /// <summary>

@ -5,6 +5,7 @@ using System.ComponentModel.DataAnnotations.Schema;
using System.Linq; using System.Linq;
using Newtonsoft.Json; using Newtonsoft.Json;
using Yavsc.Abstract.Identity.Security; using Yavsc.Abstract.Identity.Security;
using Yavsc.Attributes.Validation;
using Yavsc.Interfaces; using Yavsc.Interfaces;
using Yavsc.Models.Access; using Yavsc.Models.Access;
using Yavsc.Models.Relationship; using Yavsc.Models.Relationship;
@ -17,19 +18,19 @@ namespace Yavsc.Models.Blog
[Display(Name="Identifiant du post")] [Display(Name="Identifiant du post")]
public long Id { get; set; } public long Id { get; set; }
[Display(Name="Contenu")][StringLength(56224)] [Display(Name="Contenu")][YaStringLength(56224)]
public string Content { get; set; } public string Content { get; set; }
[Display(Name="Photo")][StringLength(1024)] [Display(Name="Photo")][YaStringLength(1024)]
public string Photo { get; set; } public string Photo { get; set; }
[StringLength(8)] [YaStringLength(8)]
public string Lang { get; set; } public string Lang { get; set; }
[Display(Name="Indice de qualité")] [Display(Name="Indice de qualité")]
public int Rate { get; set; } public int Rate { get; set; }
[Display(Name="Titre")][StringLength(1024)] [Display(Name="Titre")][YaStringLength(1024)]
public string Title { get; set; } public string Title { get; set; }
[Display(Name="Identifiant de l'auteur")] [Display(Name="Identifiant de l'auteur")]

@ -13,7 +13,7 @@ namespace Yavsc.Models.Blog
[Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)] [Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; } public long Id { get; set; }
[StringLength(1024)] [YaStringLength(1024)]
public string Content { get; set; } public string Content { get; set; }
[ForeignKeyAttribute("PostId")][JsonIgnore] [ForeignKeyAttribute("PostId")][JsonIgnore]

@ -5,6 +5,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json; using Newtonsoft.Json;
using Yavsc.Abstract.Chat; using Yavsc.Abstract.Chat;
using Yavsc.Attributes.Validation;
namespace Yavsc.Models.Chat namespace Yavsc.Models.Chat
{ {
@ -13,7 +14,7 @@ namespace Yavsc.Models.Chat
public string Topic { get; set; } public string Topic { get; set; }
[Key] [Key]
[StringLengthAttribute(ChatHubConstants.MaxChanelName, MinimumLength=3)] [YaStringLength(ChatHubConstants.MaxChanelName, MinimumLength=3)]
public string Name { get; set;} public string Name { get; set;}
public string OwnerId { get; set; } public string OwnerId { get; set; }

@ -13,6 +13,7 @@ using Microsoft.Extensions.Localization;
using Yavsc.ViewModels.PayPal; using Yavsc.ViewModels.PayPal;
using Yavsc.Models.HairCut; using Yavsc.Models.HairCut;
using Yavsc.Abstract.Identity; using Yavsc.Abstract.Identity;
using Yavsc.Attributes.Validation;
namespace Yavsc.Models.Haircut namespace Yavsc.Models.Haircut
{ {
@ -65,8 +66,7 @@ namespace Yavsc.Models.Haircut
set; set;
} }
[Display(Name = "Informations complémentaires"), [Display(Name = "Informations complémentaires"), YaStringLength(512)]
StringLengthAttribute(512)]
[DisplayFormat(ConvertEmptyStringToNull = true, NullDisplayText = "[pas d'informations complémentaires]")] [DisplayFormat(ConvertEmptyStringToNull = true, NullDisplayText = "[pas d'informations complémentaires]")]
public string AdditionalInfo { get; set; } public string AdditionalInfo { get; set; }

@ -9,10 +9,10 @@ namespace Yavsc.Models.IT.Evolution
[Key,DatabaseGenerated(DatabaseGeneratedOption.Identity)] [Key,DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; } public long Id { get; set; }
[StringLength(256)] [YaStringLength(256)]
public string ShortName { get; set; } public string ShortName { get; set; }
[StringLength(10*1024)] [YaStringLength(10*1024)]
public string Description { get; set; } public string Description { get; set; }
public FeatureStatus Status { get; set; } public FeatureStatus Status { get; set; }

@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Linq; using System.Linq;
using Yavsc.Abstract.IT; using Yavsc.Abstract.IT;
using Yavsc.Attributes.Validation;
using Yavsc.Billing; using Yavsc.Billing;
using Yavsc.Models.Billing; using Yavsc.Models.Billing;
using Yavsc.Server.Models.IT.SourceCode; 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. /// As a side effect, there's no project without valid git reference in db.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[Required] [YaRequired]
public string Name { get; set; } public string Name { get; set; }
public string Version { get; set; } public string Version { get; set; }
@ -32,7 +33,7 @@ namespace Yavsc.Server.Models.IT
public virtual List<ProjectBuildConfiguration> Configurations { get; set; } public virtual List<ProjectBuildConfiguration> Configurations { get; set; }
[Required] [YaRequired]
public long GitId { get; set; } public long GitId { get; set; }
[ForeignKey("GitId")] [ForeignKey("GitId")]

@ -1,5 +1,6 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Yavsc.Attributes.Validation;
namespace Yavsc.Server.Models.IT namespace Yavsc.Server.Models.IT
{ {
@ -12,7 +13,7 @@ namespace Yavsc.Server.Models.IT
[Key,DatabaseGenerated(DatabaseGeneratedOption.Identity)] [Key,DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; } public long Id { get; set; }
[Required] [YaRequired]
public string Name { get; set; } public string Name { get; set; }
public long ProjectId { get; set; } public long ProjectId { get; set; }

@ -1,5 +1,6 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Yavsc.Attributes.Validation;
using Yavsc.Models; using Yavsc.Models;
namespace Yavsc.Server.Models.IT.SourceCode namespace Yavsc.Server.Models.IT.SourceCode
@ -9,16 +10,16 @@ namespace Yavsc.Server.Models.IT.SourceCode
[Key,DatabaseGenerated(DatabaseGeneratedOption.Identity)] [Key,DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; } public long Id { get; set; }
[Required] [YaRequired]
public string Path { get; set; } public string Path { get; set; }
[StringLength(2048)] [YaStringLength(2048)]
public string Url { get; set; } public string Url { get; set; }
[StringLength(512)] [YaStringLength(512)]
public string Branch { get; set; } public string Branch { get; set; }
[StringLength(1024)] [YaStringLength(1024)]
public string OwnerId { get; set; } public string OwnerId { get; set; }
[ForeignKey("OwnerId")] [ForeignKey("OwnerId")]

@ -25,6 +25,8 @@ using System.ComponentModel.DataAnnotations;
namespace Yavsc.Models.Messaging namespace Yavsc.Models.Messaging
{ {
using Models.Relationship; using Models.Relationship;
using Yavsc.Attributes.Validation;
/// <summary> /// <summary>
/// Event pub. /// Event pub.
/// </summary> /// </summary>
@ -34,8 +36,7 @@ namespace Yavsc.Models.Messaging
/// Gets or sets the circles. /// Gets or sets the circles.
/// </summary> /// </summary>
/// <value>The circles.</value> /// <value>The circles.</value>
[Required(ErrorMessageResourceName="Circles"), [YaRequired, Display(Name="Circles")]
Display(Name="Circles")]
public virtual List<Circle> Circles{ get; set; } public virtual List<Circle> Circles{ get; set; }
public override string CreateBody() public override string CreateBody()

@ -1,17 +1,18 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Yavsc.Attributes.Validation;
namespace Yavsc.Models.Messaging namespace Yavsc.Models.Messaging
{ {
public class DimissClicked public class DimissClicked
{ {
[Required] [YaRequired]
public string UserId { get; set; } public string UserId { get; set; }
[ForeignKey("UserId")] [ForeignKey("UserId")]
public virtual ApplicationUser User { get; set; } public virtual ApplicationUser User { get; set; }
[Required] [YaRequired]
public long NotificationId { get; set; } public long NotificationId { get; set; }
[ForeignKey("NotificationId")] [ForeignKey("NotificationId")]

@ -2,6 +2,7 @@ using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Yavsc.Abstract.Streaming; using Yavsc.Abstract.Streaming;
using Yavsc.Attributes.Validation;
namespace Yavsc.Models.Streaming namespace Yavsc.Models.Streaming
{ {
@ -18,29 +19,29 @@ namespace Yavsc.Models.Streaming
/// a title for this flow /// a title for this flow
/// </summary> /// </summary>
/// <value></value> /// <value></value>
[StringLength(255)] [YaStringLength(255)]
[Display(Name="TitleLabel", ResourceType=typeof(LiveFlow))] [Display(Name="TitleLabel", ResourceType=typeof(LiveFlow))]
public string Title { get; set; } public string Title { get; set; }
// a little description // a little description
[StringLength(1023)] [YaStringLength(1023)]
[Display(Name="PitchLabel", ResourceType=typeof(LiveFlow))] [Display(Name="PitchLabel", ResourceType=typeof(LiveFlow))]
public string Pitch { get; set; } public string Pitch { get; set; }
// The stream type // The stream type
[StringLength(127)] [YaStringLength(127)]
[Display(Name="MediaTypeLabel", ResourceType=typeof(LiveFlow))] [Display(Name="MediaTypeLabel", ResourceType=typeof(LiveFlow))]
public string MediaType { get; set; } public string MediaType { get; set; }
// A name where to save this stream, relative to user's files root // A name where to save this stream, relative to user's files root
[StringLength(255)] [YaStringLength(255)]
[Display(Name="DifferedFileNameLabel", ResourceType=typeof(LiveFlow))] [Display(Name="DifferedFileNameLabel", ResourceType=typeof(LiveFlow))]
public string DifferedFileName { get; set; } public string DifferedFileName { get; set; }
[Display(Name="SequenceNumberLabel", ResourceType=typeof(LiveFlow))] [Display(Name="SequenceNumberLabel", ResourceType=typeof(LiveFlow))]
public int SequenceNumber { get; set; } public int SequenceNumber { get; set; }
[Required] [YaRequired]
[Display(Name="OwnerIdLabel", ResourceType=typeof(LiveFlow))] [Display(Name="OwnerIdLabel", ResourceType=typeof(LiveFlow))]
public string OwnerId {get; set; } public string OwnerId {get; set; }

@ -1,5 +1,6 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Yavsc.Attributes.Validation;
namespace Yavsc.Models.Musical namespace Yavsc.Models.Musical
{ {
@ -9,7 +10,7 @@ namespace Yavsc.Models.Musical
[Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)] [Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id {get; set; } public long Id {get; set; }
[MaxLength(255),Required] [MaxLength(255), YaRequired]
public string Name { get ; set; } public string Name { get ; set; }
} }
} }

@ -1,5 +1,6 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Yavsc.Attributes.Validation;
using Yavsc.Models.Workflow; using Yavsc.Models.Workflow;
namespace Yavsc.Models.Musical namespace Yavsc.Models.Musical
@ -9,7 +10,7 @@ namespace Yavsc.Models.Musical
[Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)] [Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id {get; set; } public long Id {get; set; }
[Required] [YaRequired]
public long InstrumentId { get; set; } public long InstrumentId { get; set; }
[ForeignKey("InstrumentId")] [ForeignKey("InstrumentId")]

@ -1,5 +1,6 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Yavsc.Attributes.Validation;
namespace Yavsc.Models.Musical namespace Yavsc.Models.Musical
{ {
@ -15,7 +16,7 @@ namespace Yavsc.Models.Musical
public int Rate { get; set; } public int Rate { get; set; }
[Required] [YaRequired]
public long TendencyId {get; set; } public long TendencyId {get; set; }
} }

@ -1,19 +1,15 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Yavsc.Attributes.Validation;
namespace Yavsc.Models.Musical { namespace Yavsc.Models.Musical {
public class MusicalTendency { public class MusicalTendency {
[Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)] [Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id {get; set; } public long Id {get; set; }
[MaxLength(255),Required] [MaxLength(255),YaRequired]
public string Name { get ; set; } public string Name { get ; set; }
} }

@ -6,13 +6,14 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace Yavsc.Models.Payment { namespace Yavsc.Models.Payment {
using Yavsc; using Yavsc;
using Relationship; using Relationship;
using Yavsc.Attributes.Validation;
public class PayPalPayment : IBaseTrackedEntity public class PayPalPayment : IBaseTrackedEntity
{ {
[Required,Key] [YaRequired,Key]
public string CreationToken { get; set; } public string CreationToken { get; set; }
[Required] [YaRequired]
public string ExecutorId { get; set; } public string ExecutorId { get; set; }
[ForeignKey("ExecutorId")] [ForeignKey("ExecutorId")]
public virtual ApplicationUser Executor { get; set; } public virtual ApplicationUser Executor { get; set; }

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json; using Newtonsoft.Json;
using Yavsc.Attributes.Validation;
namespace Yavsc.Models.Relationship namespace Yavsc.Models.Relationship
{ {
@ -13,10 +14,10 @@ namespace Yavsc.Models.Relationship
public bool Public { get; set; } public bool Public { get; set; }
[Required] [YaRequired]
public string Name { get; set; } public string Name { get; set; }
[Required] [YaRequired]
public string OwnerId { get; set; } public string OwnerId { get; set; }
[ForeignKey("OwnerId"),JsonIgnore,NotMapped] [ForeignKey("OwnerId"),JsonIgnore,NotMapped]

@ -1,6 +1,7 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Yavsc.Attributes.Validation;
namespace Yavsc.Models.Relationship namespace Yavsc.Models.Relationship
{ {
@ -8,13 +9,13 @@ namespace Yavsc.Models.Relationship
public partial class CircleMember public partial class CircleMember
{ {
[Required] [YaRequired]
public long CircleId { get; set; } public long CircleId { get; set; }
[ForeignKey("CircleId")] [ForeignKey("CircleId")]
public virtual Circle Circle { get; set; } public virtual Circle Circle { get; set; }
[Required] [YaRequired]
public string MemberId { get; set; } public string MemberId { get; set; }
[ForeignKey("MemberId")] [ForeignKey("MemberId")]

@ -1,15 +1,16 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json; using Newtonsoft.Json;
using Yavsc.Attributes.Validation;
namespace Yavsc.Models.Relationship namespace Yavsc.Models.Relationship
{ {
public class Contact: IContact public class Contact: IContact
{ {
[Required()] [YaRequired()]
public string UserId { get; set; } public string UserId { get; set; }
[Required()] [YaRequired()]
public string OwnerId { get; set; } public string OwnerId { get; set; }
public string Name { get; set; } public string Name { get; set; }

@ -1,5 +1,6 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Yavsc.Attributes.Validation;
namespace Yavsc.Models.Relationship namespace Yavsc.Models.Relationship
{ {
@ -12,7 +13,7 @@ namespace Yavsc.Models.Relationship
/// <summary> /// <summary>
/// The longitude. /// The longitude.
/// </summary> /// </summary>
[Required(),Display(Name="Longitude")] [YaRequired(),Display(Name="Longitude")]
[Range(-180, 360.0)] [Range(-180, 360.0)]
public double Longitude { get; set; } public double Longitude { get; set; }
@ -21,7 +22,7 @@ namespace Yavsc.Models.Relationship
/// ///
/// The latitude. /// The latitude.
/// </summary> /// </summary>
[Required(),Display(Name="Latitude")] [YaRequired(),Display(Name="Latitude")]
[Range(-90, 90 )] [Range(-90, 90 )]
public double Latitude { get; set; } public double Latitude { get; set; }
@ -30,7 +31,7 @@ namespace Yavsc.Models.Relationship
public class Location : Position, ILocation { public class Location : Position, ILocation {
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; } public long Id { get; set; }
[Required(), [YaRequired(),
Display(Name="Address"), Display(Name="Address"),
MaxLength(512)] MaxLength(512)]
public string Address { get; set; } public string Address { get; set; }

@ -1,6 +1,7 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Yavsc.Attributes.Validation;
namespace Yavsc.Models.Relationship namespace Yavsc.Models.Relationship
{ {
@ -8,7 +9,7 @@ namespace Yavsc.Models.Relationship
{ {
[Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)] [Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; } public long Id { get; set; }
[Required()] [YaRequired()]
public string Name { get; set; } public string Name { get; set; }
} }
} }

@ -9,22 +9,23 @@ namespace Yavsc.Models.Workflow
{ {
using Yavsc.Models.Market; using Yavsc.Models.Market;
using Yavsc; using Yavsc;
using Yavsc.Attributes.Validation;
public class Activity : IBaseTrackedEntity, IActivity public class Activity : IBaseTrackedEntity, IActivity
{ {
[StringLength(512), Required, Key] [YaStringLength(512), YaRequired, Key]
[Display(Name = "Code")] [Display(Name = "Code")]
public string Code { get; set; } public string Code { get; set; }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[StringLength(512), Required()] [YaStringLength(512), YaRequired()]
[Display(Name = "Nom")] [Display(Name = "Nom")]
public string Name { get; set; } public string Name { get; set; }
[StringLength(512)] [YaStringLength(512)]
[Display(Name = "Code du parent")] [Display(Name = "Code du parent")]
public string ParentCode { get; set; } public string ParentCode { get; set; }

@ -5,6 +5,8 @@ using Newtonsoft.Json;
namespace Yavsc.Models.Workflow namespace Yavsc.Models.Workflow
{ {
using Yavsc; using Yavsc;
using Yavsc.Attributes.Validation;
public class CommandForm : ICommandForm public class CommandForm : ICommandForm
{ {
[Key,DatabaseGenerated(DatabaseGeneratedOption.Identity)] [Key,DatabaseGenerated(DatabaseGeneratedOption.Identity)]
@ -14,7 +16,7 @@ namespace Yavsc.Models.Workflow
public string Title { get; set; } public string Title { get; set; }
[Required] [YaRequired]
public string ActivityCode { get; set; } public string ActivityCode { get; set; }
[ForeignKey("ActivityCode"),JsonIgnore] [ForeignKey("ActivityCode"),JsonIgnore]

@ -7,6 +7,7 @@ namespace Yavsc.Models.Workflow
using System; using System;
using Models.Relationship; using Models.Relationship;
using Newtonsoft.Json; using Newtonsoft.Json;
using Yavsc.Attributes.Validation;
using Yavsc.Workflow; using Yavsc.Workflow;
public class PerformerProfile : IPerformerProfile { public class PerformerProfile : IPerformerProfile {
@ -20,13 +21,13 @@ namespace Yavsc.Models.Workflow
[Display(Name="Activity"), JsonIgnore] [Display(Name="Activity"), JsonIgnore]
public virtual List<UserActivity> Activity { get; set; } public virtual List<UserActivity> 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")] RegularExpression(@"^[0-9]{9,14}$", ErrorMessage = "Only numbers are allowed here")]
public string SIREN { get; set; } public string SIREN { get; set; }
public long OrganizationAddressId { 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; } public virtual Location OrganizationAddress { get; set; }
[Display(Name="Accept notifications on client query")] [Display(Name="Accept notifications on client query")]

@ -6,6 +6,7 @@ using Yavsc.Models.Market;
namespace Yavsc.Models.Workflow namespace Yavsc.Models.Workflow
{ {
using Models.Relationship; using Models.Relationship;
using Yavsc.Attributes.Validation;
/// <summary> /// <summary>
/// A date, between two persons /// A date, between two persons
@ -17,21 +18,21 @@ namespace Yavsc.Models.Workflow
/// Event date /// Event date
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[Required(),Display(Name="EventDate")] [YaRequired(),Display(Name="EventDate")]
public DateTime EventDate { get; set; } public DateTime EventDate { get; set; }
/// <summary> /// <summary>
/// Location identifier /// Location identifier
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[Required] [YaRequired]
public long LocationId { get; set; } public long LocationId { get; set; }
/// <summary> /// <summary>
/// A Location for this event /// A Location for this event
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[Required(ErrorMessage="SpecifyPlace"),Display(Name="Location"),ForeignKey("LocationId")] [YaRequired(ErrorMessage="SpecifyPlace"),Display(Name="Location"),ForeignKey("LocationId")]
public Location Location { get; set; } public Location Location { get; set; }
} }

@ -1,18 +1,19 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json; using Newtonsoft.Json;
using Yavsc.Attributes.Validation;
namespace Yavsc.Models.Workflow namespace Yavsc.Models.Workflow
{ {
public class UserActivity public class UserActivity
{ {
[Required] [YaRequired]
public string UserId { get; set; } public string UserId { get; set; }
[ForeignKey("UserId")] [ForeignKey("UserId")]
public virtual PerformerProfile User { get; set; } public virtual PerformerProfile User { get; set; }
[Required] [YaRequired]
public string DoesCode { get; set; } public string DoesCode { get; set; }
[ForeignKey("DoesCode")] [ForeignKey("DoesCode")]

@ -1,18 +1,19 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Yavsc.Attributes.Validation;
namespace Yavsc.Models.Account {  namespace Yavsc.Models.Account { 
public class ChangePasswordBindingModel { public class ChangePasswordBindingModel {
[Required] [YaRequired]
[DataType(DataType.Password)] [DataType(DataType.Password)]
public string OldPassword { get; set; } public string OldPassword { get; set; }
[Required] [YaRequired]
[DataType(DataType.Password)] [DataType(DataType.Password)]
public string NewPassword { get; set; } public string NewPassword { get; set; }
} }
public class SetPasswordBindingModel { public class SetPasswordBindingModel {
[Required] [YaRequired]
[DataType(DataType.Password)] [DataType(DataType.Password)]
public string NewPassword { get; set; } public string NewPassword { get; set; }

@ -6,12 +6,12 @@ namespace Yavsc.ViewModels.Account
{ {
public class ExternalLoginConfirmationViewModel public class ExternalLoginConfirmationViewModel
{ {
[Required] [YaRequired]
[YaStringLength(2,Constants.MaxUserNameLength)] [YaStringLength(2,Constants.MaxUserNameLength)]
[YaRegularExpression(Constants.UserNameRegExp)] [YaRegularExpression(Constants.UserNameRegExp)]
public string Name { get; set; } public string Name { get; set; }
[Required] [YaRequired]
[EmailAddress] [EmailAddress]
public string Email { get; set; } public string Email { get; set; }

@ -1,12 +1,13 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Yavsc.Attributes.Validation;
namespace Yavsc.ViewModels.Account namespace Yavsc.ViewModels.Account
{ {
public class ForgotPasswordViewModel public class ForgotPasswordViewModel
{ {
[Required] [YaRequired]
[StringLength(512)] [YaStringLength(512)]
public string LoginOrEmail { get; set; } public string LoginOrEmail { get; set; }
} }
} }

@ -1,6 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Yavsc.Attributes.Validation;
namespace Yavsc.ViewModels.Account namespace Yavsc.ViewModels.Account
{ {
@ -10,14 +11,14 @@ namespace Yavsc.ViewModels.Account
/// Local user's name. /// Local user's name.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[Required] [YaRequired]
public string UserName { get; set; } public string UserName { get; set; }
/// <summary> /// <summary>
/// Local user's password . /// Local user's password .
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[Required] [YaRequired]
[DataType(DataType.Password)] [DataType(DataType.Password)]
public string Password { get; set; } public string Password { get; set; }

@ -11,7 +11,7 @@ namespace Yavsc.ViewModels.Account
[YaRegularExpression(Constants.UserNameRegExp)] [YaRegularExpression(Constants.UserNameRegExp)]
public string UserName { get; set; } public string UserName { get; set; }
[Required()] [YaRequired()]
[YaStringLength(2,102)] [YaStringLength(2,102)]
// [EmailAddress] // [EmailAddress]
[Display(Name = "Email")] [Display(Name = "Email")]

@ -1,15 +1,16 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Yavsc.Attributes.Validation;
namespace Yavsc.ViewModels.Account namespace Yavsc.ViewModels.Account
{ {
public class ResetPasswordViewModel public class ResetPasswordViewModel
{ {
[Required] [YaRequired]
[EmailAddress] [EmailAddress]
public string Email { get; set; } public string Email { get; set; }
[Required] [YaRequired]
[StringLength(100, ErrorMessage = "Le {0} doit être long d'au moins {2} caractères.", MinimumLength = 6)] [YaStringLength(100, ErrorMessage = "Le {0} doit être long d'au moins {2} caractères.", MinimumLength = 6)]
[DataType(DataType.Password)] [DataType(DataType.Password)]
public string Password { get; set; } public string Password { get; set; }

@ -1,10 +1,11 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Yavsc.Attributes.Validation;
namespace Yavsc.ViewModels.Account namespace Yavsc.ViewModels.Account
{ {
public class UnregisterViewModel public class UnregisterViewModel
{ {
[Required] [YaRequired]
public string UserId { get; set; } public string UserId { get; set; }
public string ReturnUrl { get; set; } public string ReturnUrl { get; set; }

@ -1,13 +1,14 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Yavsc.Attributes.Validation;
namespace Yavsc.ViewModels.Account namespace Yavsc.ViewModels.Account
{ {
public class VerifyCodeViewModel public class VerifyCodeViewModel
{ {
[Required] [YaRequired]
public string Provider { get; set; } public string Provider { get; set; }
[Required] [YaRequired]
public string Code { get; set; } public string Code { get; set; }
public string ReturnUrl { get; set; } public string ReturnUrl { get; set; }

@ -1,10 +1,11 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Yavsc.Attributes.Validation;
namespace Yavsc.ViewModels.Manage namespace Yavsc.ViewModels.Manage
{ {
public class AddPhoneNumberViewModel public class AddPhoneNumberViewModel
{ {
[Required] [YaRequired]
[Phone] [Phone]
[Display(Name = "Phone number")] [Display(Name = "Phone number")]
public string PhoneNumber { get; set; } public string PhoneNumber { get; set; }

@ -1,16 +1,17 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Yavsc.Attributes.Validation;
namespace Yavsc.ViewModels.Manage namespace Yavsc.ViewModels.Manage
{ {
public class ChangePasswordViewModel public class ChangePasswordViewModel
{ {
[Required] [YaRequired]
[DataType(DataType.Password)] [DataType(DataType.Password)]
[Display(Name = "Current password")] [Display(Name = "Current password")]
public string OldPassword { get; set; } public string OldPassword { get; set; }
[Required] [YaRequired]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)] [YaStringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)] [DataType(DataType.Password)]
[Display(Name = "New password")] [Display(Name = "New password")]
public string NewPassword { get; set; } public string NewPassword { get; set; }

@ -1,35 +1,36 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Yavsc.Attributes.Validation;
namespace Yavsc.ViewModels.Manage namespace Yavsc.ViewModels.Manage
{ {
public class DoDirectCreditViewModel { public class DoDirectCreditViewModel {
[Required] [YaRequired]
public string PaymentType  { get; set;} public string PaymentType  { get; set;}
[Required] [YaRequired]
public string PayerName  { get; set;} public string PayerName  { get; set;}
[Required] [YaRequired]
public string FirstName  { get; set;} public string FirstName  { get; set;}
[Required] [YaRequired]
public string LastName  { get; set;} public string LastName  { get; set;}
[Required] [YaRequired]
public string CreditCardNumber  { get; set;} public string CreditCardNumber  { get; set;}
public string CreditCardType  { get; set;} public string CreditCardType  { get; set;}
public string Cvv2Number  { get; set;} public string Cvv2Number  { get; set;}
public string CardExpiryDate  { get; set;} public string CardExpiryDate  { get; set;}
public string IpnNotificationUrl { get; set; } public string IpnNotificationUrl { get; set; }
[Required] [YaRequired]
public string Street1 { get; set; } public string Street1 { get; set; }
public string Street2 { get; set; } public string Street2 { get; set; }
public string City { get; set; } public string City { get; set; }
public string State { get; set; } public string State { get; set; }
public string Country { get; set; } public string Country { get; set; }
[Required] [YaRequired]
public string PostalCode { get; set; } public string PostalCode { get; set; }
public string Phone { get; set; } public string Phone { get; set; }
[Required] [YaRequired]
public string CurrencyCode { get; set; } public string CurrencyCode { get; set; }
[Required] [YaRequired]
public string Amount { get; set; } public string Amount { get; set; }
} }
} }

@ -1,16 +1,17 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Yavsc.Attributes.Validation;
namespace Yavsc.ViewModels.Manage namespace Yavsc.ViewModels.Manage
{ {
public class SetAddressViewModel public class SetAddressViewModel
{ {
[Required] [YaRequired]
public string Street1 { get; set; } public string Street1 { get; set; }
public string Street2 { get; set; } public string Street2 { get; set; }
public string City { get; set; } public string City { get; set; }
public string State { get; set; } public string State { get; set; }
public string Country { get; set; } public string Country { get; set; }
[Required] [YaRequired]
public string PostalCode { get; set; } public string PostalCode { get; set; }
} }
} }

@ -1,11 +1,12 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Yavsc.Attributes.Validation;
namespace Yavsc.ViewModels.Manage namespace Yavsc.ViewModels.Manage
{ {
public class SetPasswordViewModel public class SetPasswordViewModel
{ {
[Required] [YaRequired]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)] [YaStringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)] [DataType(DataType.Password)]
[Display(Name = "New password")] [Display(Name = "New password")]
public string NewPassword { get; set; } public string NewPassword { get; set; }

@ -1,13 +1,14 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Yavsc.Attributes.Validation;
namespace Yavsc.ViewModels.Manage namespace Yavsc.ViewModels.Manage
{ {
public class VerifyPhoneNumberViewModel public class VerifyPhoneNumberViewModel
{ {
[Required] [YaRequired]
public string Code { get; set; } public string Code { get; set; }
[Required] [YaRequired]
[Phone] [Phone]
[Display(Name = "Phone number")] [Display(Name = "Phone number")]
public string PhoneNumber { get; set; } public string PhoneNumber { get; set; }

@ -13,10 +13,7 @@ namespace Yavsc.ApiControllers
using Yavsc.Helpers; using Yavsc.Helpers;
using Yavsc.Exceptions; using Yavsc.Exceptions;
using Yavsc.Models.FileSystem; using Yavsc.Models.FileSystem;
using System.ComponentModel.DataAnnotations;
public class FSQuotaException : Exception {
}
[Authorize,Route("api/fs")] [Authorize,Route("api/fs")]
public class FileSystemApiController : Controller public class FileSystemApiController : Controller
@ -55,6 +52,7 @@ namespace Yavsc.ApiControllers
[HttpPost("{*subdir}")] [HttpPost("{*subdir}")]
public IActionResult Post(string subdir="") public IActionResult Post(string subdir="")
{ {
string destDir = null; string destDir = null;
List<FileRecievedInfo> received = new List<FileRecievedInfo>(); List<FileRecievedInfo> received = new List<FileRecievedInfo>();
InvalidPathException pathex = null; InvalidPathException pathex = null;
@ -89,7 +87,7 @@ namespace Yavsc.ApiControllers
return Ok(received); return Ok(received);
} }
[Route("/api/fsquota/add/{uname}/{len}")] [Route("/api/fsc/addquota/{uname}/{len}")]
[Authorize("AdministratorOnly")] [Authorize("AdministratorOnly")]
public IActionResult AddQuota(string uname, int len) public IActionResult AddQuota(string uname, int len)
{ {
@ -102,7 +100,7 @@ namespace Yavsc.ApiControllers
return Ok(len); return Ok(len);
} }
[Route("/api/movefile")] [Route("/api/fsc/movefile")]
[Authorize()] [Authorize()]
public IActionResult MoveFile(string from, string to) public IActionResult MoveFile(string from, string to)
{ {
@ -110,11 +108,14 @@ namespace Yavsc.ApiControllers
var user = dbContext.Users.Single( var user = dbContext.Users.Single(
u => u.Id == uid u => u.Id == uid
); );
throw new NotImplementedException(); var info = user.MoveUserFile(from, to);
if (!info.Done)
return new BadRequestObjectResult(info);
return Ok(); return Ok();
} }
[Route("/api/movedir")] [HttpPatch]
[Route("/api/fsc/movedir")]
[Authorize()] [Authorize()]
public IActionResult MoveDir(string from, string to) public IActionResult MoveDir(string from, string to)
{ {
@ -122,29 +123,67 @@ namespace Yavsc.ApiControllers
var user = dbContext.Users.Single( var user = dbContext.Users.Single(
u => u.Id == uid 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(); return Ok();
} }
[HttpDelete] [HttpDelete]
[Route("/api/fsc/rm/{*id}")]
public async Task <IActionResult> Delete (string id) public async Task <IActionResult> Delete (string id)
{ {
var user = dbContext.Users.Single( var user = dbContext.Users.Single(
u => u.Id == User.GetUserId() u => u.Id == User.GetUserId()
); );
InvalidPathException pathex = null;
string root = null;
try { try {
root = User.InitPostToFileSystem(id);
} catch (InvalidPathException ex) {
pathex = ex;
}
if (pathex!=null)
return new BadRequestObjectResult(pathex);
user.DeleteUserFile(id); user.DeleteUserFile(id);
await dbContext.SaveChangesAsync(User.GetUserId()); await dbContext.SaveChangesAsync(User.GetUserId());
}
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 }); return Ok(new { deleted=id });
} }
} }
} }

@ -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
{
}
}

@ -7,6 +7,7 @@ using System.IO;
using System.Security.Claims; using System.Security.Claims;
using System.Threading; using System.Threading;
using System.Web; using System.Web;
using Microsoft.AspNet.FileProviders;
using Microsoft.AspNet.Http; using Microsoft.AspNet.Http;
using Yavsc.Exceptions; using Yavsc.Exceptions;
using Yavsc.Models; using Yavsc.Models;
@ -103,6 +104,58 @@ namespace Yavsc.Helpers
user.DiskUsage -= fi.Length; 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) static string ParseFileNameFromDisposition(string disposition)
{ {
// form-data_ name=_file__ filename=_Constants.Private.cs_ // form-data_ name=_file__ filename=_Constants.Private.cs_
@ -167,6 +220,15 @@ namespace Yavsc.Helpers
return new HtmlString( return new HtmlString(
$"{Startup.UserFilesOptions.RequestPath}/{username}/{subpath}/{info.Name}" ); $"{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) public static FileRecievedInfo ReceiveAvatar(this ApplicationUser user, IFormFile formFile)
{ {
var item = new FileRecievedInfo(); var item = new FileRecievedInfo();

@ -1,16 +1,17 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Yavsc.Attributes.Validation;
namespace Yavsc.ViewModels namespace Yavsc.ViewModels
{ {
public partial class EnrolerViewModel { public partial class EnrolerViewModel {
[Display(Name="EnroledLabel", ResourceType=typeof(EnrolerViewModel))] [Display(Name="EnroledLabel", ResourceType=typeof(EnrolerViewModel))]
[Required] [YaRequired]
public string EnroledUserId { get; set; } public string EnroledUserId { get; set; }
[Display(Name="RoleNameLabel", ResourceType=typeof(EnrolerViewModel))] [Display(Name="RoleNameLabel", ResourceType=typeof(EnrolerViewModel))]
[Required] [YaRequired]
public string RoleName { get; set; } public string RoleName { get; set; }
} }
} }

@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Yavsc.Attributes.Validation;
namespace Yavsc.ViewModels namespace Yavsc.ViewModels
{ {
@ -7,12 +8,12 @@ namespace Yavsc.ViewModels
[Display(Name="EnroledLabel", ResourceType=typeof(EnrolerViewModel))] [Display(Name="EnroledLabel", ResourceType=typeof(EnrolerViewModel))]
public string EnroledUserName { get; set; } public string EnroledUserName { get; set; }
[Required] [YaRequired]
public string EnroledUserId { get; set; } public string EnroledUserId { get; set; }
[Display(Name="RoleNameLabel", ResourceType=typeof(EnrolerViewModel))] [Display(Name="RoleNameLabel", ResourceType=typeof(EnrolerViewModel))]
[Required] [YaRequired]
public string RoleName { get; set; } public string RoleName { get; set; }
} }
} }

@ -1,16 +1,17 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Microsoft.AspNet.Mvc.Rendering; using Microsoft.AspNet.Mvc.Rendering;
using Yavsc.Attributes.Validation;
namespace Yavsc.ViewModels.Gen namespace Yavsc.ViewModels.Gen
{ {
public class PdfGenerationViewModel public class PdfGenerationViewModel
{ {
[Required] [YaRequired]
public string TeXSource { get; set; } public string TeXSource { get; set; }
[Required] [YaRequired]
public string BaseFileName { get; set; } public string BaseFileName { get; set; }
[Required] [YaRequired]
public string DestDir { get; set; } public string DestDir { get; set; }
public bool Generated { get; set; } public bool Generated { get; set; }
public HtmlString GenerationErrorMessage { get; set; } public HtmlString GenerationErrorMessage { get; set; }

@ -1,11 +1,12 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Yavsc.Attributes.Validation;
namespace Yavsc.ViewModels.Manage namespace Yavsc.ViewModels.Manage
{ {
public class ChangeUserNameViewModel public class ChangeUserNameViewModel
{ {
[Required] [YaRequired]
[Display(Name = "New user name"),RegularExpression(Constants.UserNameRegExp)] [Display(Name = "New user name"),RegularExpression(Constants.UserNameRegExp)]
public string NewUserName { get; set; } public string NewUserName { get; set; }

@ -6,7 +6,7 @@ namespace Yavsc.ViewModels.Manage
{ {
public class SetFullNameViewModel public class SetFullNameViewModel
{ {
[Required] [YaRequired]
[Display(Name = "Your full name"), YaStringLength(512)] [Display(Name = "Your full name"), YaStringLength(512)]
public string FullName { get; set; } public string FullName { get; set; }
} }

@ -3,6 +3,7 @@ using System.Threading.Tasks;
using NJsonSchema; using NJsonSchema;
using System.IO; using System.IO;
using cli.Model; using cli.Model;
using Yavsc.Abstract.IT;
namespace cli namespace cli
{ {

Loading…