Using YaStringLength and YaRequired
This commit is contained in:
@ -16,8 +16,10 @@ namespace Yavsc.Attributes.Validation
|
||||
}
|
||||
public YaRequiredAttribute () : base("Required Field")
|
||||
{
|
||||
|
||||
ErrorMessageResourceType = typeof(Yavsc.Attributes.Validation.Resources);
|
||||
ErrorMessageResourceName = "FieldRequired";
|
||||
}
|
||||
|
||||
public override bool IsValid(object value) {
|
||||
if (value == null) {
|
||||
return false;
|
||||
|
@ -20,7 +20,7 @@ namespace Yavsc.Attributes.Validation
|
||||
void UseDefaultErrorMessage()
|
||||
{
|
||||
if (ErrorMessageResourceType==null) {
|
||||
ErrorMessageResourceType = typeof(YaStringLength);
|
||||
ErrorMessageResourceType = typeof(Yavsc.Attributes.Validation.Resources);
|
||||
ErrorMessageResourceName = "InvalidStringLength";
|
||||
}
|
||||
}
|
||||
|
@ -12,14 +12,24 @@ namespace Yavsc.Helpers
|
||||
public static string UserBillsDirName { 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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
7
src/Yavsc.Abstract/FileSystem/FsOperationInfo.cs
Normal file
7
src/Yavsc.Abstract/FileSystem/FsOperationInfo.cs
Normal file
@ -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
|
||||
{
|
||||
@ -12,7 +12,6 @@ namespace Yavsc.ViewModels
|
||||
|
||||
public DateTime LastModified { get; set; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -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;}
|
||||
|
||||
}
|
||||
|
@ -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;}
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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,11 +1,11 @@
|
||||
// ------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// <autogenerated>
|
||||
// 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
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
// </autogenerated>
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
namespace Yavsc.Attributes.Validation {
|
||||
@ -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);
|
@ -61,6 +61,6 @@
|
||||
<!--
|
||||
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>
|
||||
|
||||
</root>
|
@ -61,6 +61,6 @@
|
||||
<!--
|
||||
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>
|
||||
|
||||
</root>
|
@ -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
|
||||
/// </summary>
|
||||
/// <value>The BI.</value>
|
||||
[DisplayName("Code BIC")]
|
||||
[StringLength(15)]
|
||||
[YaStringLength(15)]
|
||||
public string BIC { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@ -22,7 +23,7 @@ namespace Yavsc.Models.Bank
|
||||
/// </summary>
|
||||
/// <value>The IBA.</value>
|
||||
[DisplayName("Code IBAN")]
|
||||
[StringLength(33)]
|
||||
[YaStringLength(33)]
|
||||
public string IBAN { get; set; }
|
||||
|
||||
|
||||
@ -31,7 +32,7 @@ namespace Yavsc.Models.Bank
|
||||
/// </summary>
|
||||
/// <value>The bank code.</value>
|
||||
[DisplayName("Code Banque")]
|
||||
[StringLength(5)]
|
||||
[YaStringLength(5)]
|
||||
public string BankCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@ -39,7 +40,7 @@ namespace Yavsc.Models.Bank
|
||||
/// </summary>
|
||||
/// <value>The wicket code.</value>
|
||||
[DisplayName("Code Guichet")]
|
||||
[StringLength(5)]
|
||||
[YaStringLength(5)]
|
||||
public string WicketCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@ -47,7 +48,7 @@ namespace Yavsc.Models.Bank
|
||||
/// </summary>
|
||||
/// <value>The account number.</value>
|
||||
[DisplayName("Numéro de compte")]
|
||||
[StringLength(15)]
|
||||
[YaStringLength(15)]
|
||||
public string AccountNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
@ -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")]
|
||||
|
@ -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]
|
||||
|
@ -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; }
|
||||
|
@ -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; }
|
||||
|
||||
|
@ -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; }
|
||||
|
@ -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.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Required]
|
||||
[YaRequired]
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Version { get; set; }
|
||||
@ -32,7 +33,7 @@ namespace Yavsc.Server.Models.IT
|
||||
public virtual List<ProjectBuildConfiguration> Configurations { get; set; }
|
||||
|
||||
|
||||
[Required]
|
||||
[YaRequired]
|
||||
public long GitId { get; set; }
|
||||
|
||||
[ForeignKey("GitId")]
|
||||
|
@ -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; }
|
||||
|
@ -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")]
|
||||
|
@ -25,6 +25,8 @@ using System.ComponentModel.DataAnnotations;
|
||||
namespace Yavsc.Models.Messaging
|
||||
{
|
||||
using Models.Relationship;
|
||||
using Yavsc.Attributes.Validation;
|
||||
|
||||
/// <summary>
|
||||
/// Event pub.
|
||||
/// </summary>
|
||||
@ -34,8 +36,7 @@ namespace Yavsc.Models.Messaging
|
||||
/// Gets or sets the circles.
|
||||
/// </summary>
|
||||
/// <value>The circles.</value>
|
||||
[Required(ErrorMessageResourceName="Circles"),
|
||||
Display(Name="Circles")]
|
||||
[YaRequired, Display(Name="Circles")]
|
||||
public virtual List<Circle> Circles{ get; set; }
|
||||
|
||||
public override string CreateBody()
|
||||
|
@ -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")]
|
||||
|
@ -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
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
[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; }
|
||||
|
||||
|
@ -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; }
|
||||
}
|
||||
}
|
@ -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")]
|
||||
|
@ -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; }
|
||||
}
|
||||
|
||||
|
@ -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; }
|
||||
|
||||
}
|
||||
|
@ -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; }
|
||||
|
@ -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]
|
||||
|
@ -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")]
|
||||
|
@ -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; }
|
||||
|
@ -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
|
||||
/// <summary>
|
||||
/// The longitude.
|
||||
/// </summary>
|
||||
[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.
|
||||
/// </summary>
|
||||
[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; }
|
||||
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
@ -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; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[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; }
|
||||
|
||||
|
@ -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]
|
||||
|
@ -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<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")]
|
||||
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")]
|
||||
|
@ -6,6 +6,7 @@ using Yavsc.Models.Market;
|
||||
namespace Yavsc.Models.Workflow
|
||||
{
|
||||
using Models.Relationship;
|
||||
using Yavsc.Attributes.Validation;
|
||||
|
||||
/// <summary>
|
||||
/// A date, between two persons
|
||||
@ -17,21 +18,21 @@ namespace Yavsc.Models.Workflow
|
||||
/// Event date
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Required(),Display(Name="EventDate")]
|
||||
[YaRequired(),Display(Name="EventDate")]
|
||||
public DateTime EventDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Location identifier
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Required]
|
||||
[YaRequired]
|
||||
public long LocationId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A Location for this event
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Required(ErrorMessage="SpecifyPlace"),Display(Name="Location"),ForeignKey("LocationId")]
|
||||
[YaRequired(ErrorMessage="SpecifyPlace"),Display(Name="Location"),ForeignKey("LocationId")]
|
||||
public Location Location { get; set; }
|
||||
|
||||
}
|
||||
|
@ -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")]
|
||||
|
@ -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; }
|
||||
|
||||
|
@ -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; }
|
||||
|
||||
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Required]
|
||||
[YaRequired]
|
||||
public string UserName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Local user's password .
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[Required]
|
||||
[YaRequired]
|
||||
[DataType(DataType.Password)]
|
||||
public string Password { get; set; }
|
||||
|
||||
|
@ -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")]
|
||||
|
@ -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; }
|
||||
|
||||
|
@ -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; }
|
||||
|
@ -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; }
|
||||
|
@ -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; }
|
||||
|
@ -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; }
|
||||
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
@ -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; }
|
||||
|
@ -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; }
|
||||
|
@ -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<FileRecievedInfo> received = new List<FileRecievedInfo>();
|
||||
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 <IActionResult> 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());
|
||||
}
|
||||
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 });
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
15
src/Yavsc/ApiControllers/Blogspot/TestApiController.cs
Normal file
15
src/Yavsc/ApiControllers/Blogspot/TestApiController.cs
Normal file
@ -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.Threading;
|
||||
using System.Web;
|
||||
using Microsoft.AspNet.FileProviders;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Yavsc.Exceptions;
|
||||
using Yavsc.Models;
|
||||
@ -103,6 +104,58 @@ namespace Yavsc.Helpers
|
||||
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)
|
||||
{
|
||||
// form-data_ name=_file__ filename=_Constants.Private.cs_
|
||||
@ -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();
|
||||
|
@ -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; }
|
||||
}
|
||||
}
|
@ -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; }
|
||||
}
|
||||
}
|
@ -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; }
|
||||
|
@ -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; }
|
||||
|
||||
|
@ -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; }
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ using System.Threading.Tasks;
|
||||
using NJsonSchema;
|
||||
using System.IO;
|
||||
using cli.Model;
|
||||
using Yavsc.Abstract.IT;
|
||||
|
||||
namespace cli
|
||||
{
|
||||
|
Reference in New Issue
Block a user