BCards/src/BCards.Web/ViewModels/ManagePageViewModel.cs
Ricardo Carneiro 27ae8b606e feat:
+login ms que permite contas corporativas ou não.
+Links para produtos de afiliados
2025-06-25 19:30:19 -03:00

124 lines
4.5 KiB
C#

using System.ComponentModel.DataAnnotations;
using BCards.Web.Models;
namespace BCards.Web.ViewModels;
public class ManagePageViewModel
{
public string Id { get; set; } = string.Empty;
public bool IsNewPage { get; set; } = true;
[Required(ErrorMessage = "Nome é obrigatório")]
[StringLength(50, ErrorMessage = "Nome deve ter no máximo 50 caracteres")]
public string DisplayName { get; set; } = string.Empty;
[Required(ErrorMessage = "Categoria é obrigatória")]
public string Category { get; set; } = string.Empty;
[Required(ErrorMessage = "Tipo de negócio é obrigatório")]
public string BusinessType { get; set; } = "individual";
[StringLength(200, ErrorMessage = "Bio deve ter no máximo 200 caracteres")]
public string Bio { get; set; } = string.Empty;
public string Slug { get; set; } = string.Empty;
[Required(ErrorMessage = "Tema é obrigatório")]
public string SelectedTheme { get; set; } = "minimalist";
public string WhatsAppNumber { get; set; } = string.Empty;
public string FacebookUrl { get; set; } = string.Empty;
public string TwitterUrl { get; set; } = string.Empty;
public string InstagramUrl { get; set; } = string.Empty;
public List<ManageLinkViewModel> Links { get; set; } = new();
// Data for dropdowns and selections
public List<Category> AvailableCategories { get; set; } = new();
public List<PageTheme> AvailableThemes { get; set; } = new();
// Plan limitations
public int MaxLinksAllowed { get; set; } = 3;
public bool CanUseTheme(string themeName) => AvailableThemes.Any(t => t.Name.ToLower() == themeName.ToLower());
}
public class ManageLinkViewModel
{
public string Id { get; set; } = "new";
[Required(ErrorMessage = "Título é obrigatório")]
[StringLength(50, ErrorMessage = "Título deve ter no máximo 50 caracteres")]
public string Title { get; set; } = string.Empty;
[Required(ErrorMessage = "URL é obrigatória")]
[Url(ErrorMessage = "URL inválida")]
public string Url { get; set; } = string.Empty;
[StringLength(100, ErrorMessage = "Descrição deve ter no máximo 100 caracteres")]
public string Description { get; set; } = string.Empty;
public string Icon { get; set; } = string.Empty;
public int Order { get; set; } = 0;
public bool IsActive { get; set; } = true;
// Campos para Links de Produto
public LinkType Type { get; set; } = LinkType.Normal;
[StringLength(100, ErrorMessage = "Título do produto deve ter no máximo 100 caracteres")]
public string ProductTitle { get; set; } = string.Empty;
public string ProductImage { get; set; } = string.Empty;
[StringLength(50, ErrorMessage = "Preço deve ter no máximo 50 caracteres")]
public string ProductPrice { get; set; } = string.Empty;
[StringLength(200, ErrorMessage = "Descrição do produto deve ter no máximo 200 caracteres")]
public string ProductDescription { get; set; } = string.Empty;
public DateTime? ProductDataCachedAt { get; set; }
}
public class DashboardViewModel
{
public User CurrentUser { get; set; } = new();
public List<UserPageSummary> UserPages { get; set; } = new();
public PlanInfo CurrentPlan { get; set; } = new();
public bool CanCreateNewPage { get; set; } = false;
public int DaysRemaining { get; set; } = 0;
}
public class UserPageSummary
{
public string Id { get; set; } = string.Empty;
public string DisplayName { get; set; } = string.Empty;
public string Slug { get; set; } = string.Empty;
public string Category { get; set; } = string.Empty;
public PageStatus Status { get; set; } = PageStatus.Active;
public int TotalClicks { get; set; } = 0;
public int TotalViews { get; set; } = 0;
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public string PublicUrl => $"/page/{Category.ToLower()}/{Slug.ToLower()}";
}
public class PlanInfo
{
public PlanType Type { get; set; } = PlanType.Trial;
public string Name { get; set; } = string.Empty;
public int MaxPages { get; set; } = 1;
public int MaxLinksPerPage { get; set; } = 3;
public int DurationDays { get; set; } = 7;
public decimal Price { get; set; } = 0;
public bool AllowsAnalytics { get; set; } = false;
public bool AllowsCustomThemes { get; set; } = false;
}
public enum PageStatus
{
Active, // Funcionando normalmente
Expired, // Trial vencido -> 301 redirect
PendingPayment, // Pagamento atrasado -> aviso na página
Inactive // Pausada pelo usuário
}