Blog module consts converted to static

pull/4527/head
Ahmet Çotur 5 years ago
parent 59054a16c4
commit f7d8a96c43

@ -2,6 +2,7 @@ using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Validation;
using Volo.Blogging.Admin.Blogs;
using Volo.Blogging.Blogs;
@ -44,14 +45,14 @@ namespace Volo.Blogging.Admin.Pages.Blogging.Admin.Blogs
public class BlogCreateModalView
{
[Required]
[StringLength(BlogConsts.MaxNameLength)]
[DynamicStringLength(typeof(BlogConsts), nameof(BlogConsts.MaxNameLength))]
public string Name { get; set; }
[Required]
[StringLength(BlogConsts.MaxShortNameLength)]
[DynamicStringLength(typeof(BlogConsts), nameof(BlogConsts.MaxShortNameLength))]
public string ShortName { get; set; }
[StringLength(BlogConsts.MaxDescriptionLength)]
[DynamicStringLength(typeof(BlogConsts), nameof(BlogConsts.MaxDescriptionLength))]
public string Description { get; set; }
}

@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Validation;
using Volo.Blogging.Admin.Blogs;
using Volo.Blogging.Blogs;
@ -58,14 +59,14 @@ namespace Volo.Blogging.Admin.Pages.Blogging.Admin.Blogs
public Guid Id { get; set; }
[Required]
[StringLength(BlogConsts.MaxNameLength)]
[DynamicStringLength(typeof(BlogConsts), nameof(BlogConsts.MaxNameLength))]
public string Name { get; set; }
[Required]
[StringLength(BlogConsts.MaxShortNameLength)]
[DynamicStringLength(typeof(BlogConsts), nameof(BlogConsts.MaxShortNameLength))]
public string ShortName { get; set; }
[StringLength(BlogConsts.MaxDescriptionLength)]
[DynamicStringLength(typeof(BlogConsts), nameof(BlogConsts.MaxDescriptionLength))]
public string Description { get; set; }
}
}

@ -6,7 +6,10 @@ namespace Volo.Blogging
{
public class FileUploading
{
public const int MaxFileSize = 5242880; //5MB
/// <summary>
/// Default value: 5242880
/// </summary>
public static int MaxFileSize { get; set; } = 5242880; //5MB
public static int MaxFileSizeAsMegabytes => Convert.ToInt32((MaxFileSize / 1024f) / 1024f);
}

@ -1,5 +1,6 @@
using System;
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Validation;
namespace Volo.Blogging.Posts
{
@ -8,22 +9,22 @@ namespace Volo.Blogging.Posts
public Guid BlogId { get; set; }
[Required]
[StringLength(PostConsts.MaxTitleLength)]
[DynamicStringLength(typeof(PostConsts), nameof(PostConsts.MaxTitleLength))]
public string Title { get; set; }
[Required]
public string CoverImage { get; set; }
[Required]
[StringLength(PostConsts.MaxUrlLength)]
[DynamicStringLength(typeof(PostConsts), nameof(PostConsts.MaxUrlLength))]
public string Url { get; set; }
[StringLength(PostConsts.MaxContentLength)]
[DynamicStringLength(typeof(PostConsts), nameof(PostConsts.MaxContentLength))]
public string Content { get; set; }
public string Tags { get; set; }
[StringLength(PostConsts.MaxDescriptionLength)]
[DynamicStringLength(typeof(PostConsts), nameof(PostConsts.MaxDescriptionLength))]
public string Description { get; set; }
}

@ -2,10 +2,19 @@
{
public static class BlogConsts
{
public const int MaxNameLength = 256;
/// <summary>
/// Default value: 256
/// </summary>
public static int MaxNameLength { get; set; } = 256;
public const int MaxShortNameLength = 32;
/// <summary>
/// Default value: 32
/// </summary>
public static int MaxShortNameLength { get; set; } = 32;
public const int MaxDescriptionLength = 1024;
/// <summary>
/// Default value: 1024
/// </summary>
public static int MaxDescriptionLength { get; set; } = 1024;
}
}

@ -2,6 +2,9 @@
{
public class CommentConsts
{
public const int MaxTextLength = 1024;
/// <summary>
/// Default value: 1024
/// </summary>
public static int MaxTextLength { get; set; } = 1024;
}
}

@ -2,16 +2,34 @@
{
public static class PostConsts
{
public const int MaxTitleLength = 512;
/// <summary>
/// Default value: 512
/// </summary>
public static int MaxTitleLength { get; set; } = 512;
public const int MaxUrlLength = 64;
/// <summary>
/// Default value: 64
/// </summary>
public static int MaxUrlLength { get; set; } = 64;
public const int MaxContentLength = 1024 * 1024; //1MB
/// <summary>
/// Default value: 1024 * 1024
/// </summary>
public static int MaxContentLength { get; set; } = 1024 * 1024; //1MB
public const int MaxDescriptionLength = 1000;
/// <summary>
/// Default value: 1000
/// </summary>
public static int MaxDescriptionLength { get; set; } = 1000;
public const int MaxTitleLengthToBeSeoFriendly = 60;
/// <summary>
/// Default value: 60
/// </summary>
public static int MaxTitleLengthToBeSeoFriendly { get; set; } = 60;
public const int MaxSeoFriendlyDescriptionLength = 200;
/// <summary>
/// Default value: 200
/// </summary>
public static int MaxSeoFriendlyDescriptionLength { get; set; } = 200;
}
}

@ -2,8 +2,14 @@
{
public class TagConsts
{
public const int MaxNameLength = 64;
/// <summary>
/// Default value: 64
/// </summary>
public static int MaxNameLength { get; set; } = 64;
public const int MaxDescriptionLength = 512;
/// <summary>
/// Default value: 512
/// </summary>
public static int MaxDescriptionLength { get; set; } = 512;
}
}

@ -6,6 +6,7 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages;
using Volo.Abp.Validation;
using Volo.Blogging.Blogs;
using Volo.Blogging.Pages.Blogs.Shared.Helpers;
using Volo.Blogging.Posts;
@ -85,7 +86,7 @@ namespace Volo.Blogging.Pages.Blog.Posts
public Guid BlogId { get; set; }
[Required]
[StringLength(PostConsts.MaxTitleLength)]
[DynamicStringLength(typeof(PostConsts), nameof(PostConsts.MaxTitleLength))]
public string Title { get; set; }
[Required]
@ -93,14 +94,14 @@ namespace Volo.Blogging.Pages.Blog.Posts
public string CoverImage { get; set; }
[Required]
[StringLength(PostConsts.MaxUrlLength)]
[DynamicStringLength(typeof(PostConsts), nameof(PostConsts.MaxUrlLength))]
public string Url { get; set; }
[HiddenInput]
[StringLength(PostConsts.MaxContentLength)]
[DynamicStringLength(typeof(PostConsts), nameof(PostConsts.MaxContentLength))]
public string Content { get; set; }
[StringLength(PostConsts.MaxDescriptionLength)]
[DynamicStringLength(typeof(PostConsts), nameof(PostConsts.MaxDescriptionLength))]
public string Description { get; set; }
public string Tags { get; set; }

@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages;
using Volo.Abp.Validation;
using Volo.Blogging.Blogs;
using Volo.Blogging.Blogs.Dtos;
using Volo.Blogging.Pages.Blogs.Shared.Helpers;
@ -79,7 +80,7 @@ namespace Volo.Blogging.Pages.Blog.Posts
public Guid BlogId { get; set; }
[Required]
[StringLength(PostConsts.MaxTitleLength)]
[DynamicStringLength(typeof(PostConsts), nameof(PostConsts.MaxTitleLength))]
public string Title { get; set; }
[Required]
@ -87,16 +88,16 @@ namespace Volo.Blogging.Pages.Blog.Posts
public string CoverImage { get; set; }
[Required]
[StringLength(PostConsts.MaxUrlLength)]
[DynamicStringLength(typeof(PostConsts), nameof(PostConsts.MaxUrlLength))]
public string Url { get; set; }
[HiddenInput]
[StringLength(PostConsts.MaxContentLength)]
[DynamicStringLength(typeof(PostConsts), nameof(PostConsts.MaxContentLength))]
public string Content { get; set; }
public string Tags { get; set; }
[StringLength(PostConsts.MaxDescriptionLength)]
[DynamicStringLength(typeof(PostConsts), nameof(PostConsts.MaxDescriptionLength))]
public string Description { get; set; }
}

Loading…
Cancel
Save