using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Http;
namespace rgbc_sds.services.Models
{
///
/// View model for import file upload
///
public class ImportUploadViewModel
{
///
/// Excel file to upload
///
[Required(ErrorMessage = "Please select a file to upload")]
public IFormFile? File { get; set; }
///
/// Import strategy to use
///
[Required(ErrorMessage = "Please select an import strategy")]
public string ImportMode { get; set; } = "UpdateExisting";
///
/// Additional notes about the import
///
[StringLength(500, ErrorMessage = "Notes cannot exceed 500 characters")]
public string? Notes { get; set; }
///
/// Available import modes
///
public List AvailableImportModes { get; set; } = new()
{
new ImportModeOption { Value = "UpdateExisting", DisplayName = "Update Existing Shipments Only", Description = "Update existing shipments if Indent Number matches, skip if not found" },
new ImportModeOption { Value = "AddNewOnly", DisplayName = "Add New Shipments Only", Description = "Only create new shipments, skip existing ones" }
};
}
///
/// Import mode option for dropdown
///
public class ImportModeOption
{
public string Value { get; set; } = string.Empty;
public string DisplayName { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
}
///
/// View model for import session summary
///
public class ImportSessionViewModel
{
public Guid Id { get; set; }
public string FileName { get; set; } = string.Empty;
public string Status { get; set; } = string.Empty;
public int TotalRows { get; set; }
public int ValidRows { get; set; }
public int ErrorRows { get; set; }
public decimal SuccessRate { get; set; }
public string CreatedBy { get; set; } = string.Empty;
public DateTime CreatedAt { get; set; }
public DateTime? CompletedAt { get; set; }
public int? ProcessingTime { get; set; }
public string ImportMode { get; set; } = string.Empty;
public string? Notes { get; set; }
public bool IsActive { get; set; }
public bool IsCompleted { get; set; }
public bool CanExecute { get; set; }
public bool CanCancel { get; set; }
public bool HasErrors => ErrorRows > 0;
}
///
/// View model for staging data preview
///
public class StagingPreviewViewModel
{
public Guid SessionId { get; set; }
public string FileName { get; set; } = string.Empty;
public int TotalRecords { get; set; }
public int ValidRecords { get; set; }
public int ErrorRecords { get; set; }
public List Records { get; set; } = new List();
public int CurrentPage { get; set; }
public int PageSize { get; set; }
public int TotalPages { get; set; }
public bool HasErrors { get; set; }
public bool CanExecute { get; set; }
}
///
/// View model for individual staging record
///
public class StagingRecordViewModel
{
public long Id { get; set; }
public int RowNumber { get; set; }
public string Status { get; set; } = string.Empty;
public string SupplierName { get; set; } = string.Empty;
public string IndentNumber { get; set; } = string.Empty;
public string? ShipshapeNumber { get; set; }
public string? MotherVessel { get; set; }
public string? ETA { get; set; }
public string? BillOfEntryNumber { get; set; }
public string? ContainerNumber { get; set; }
public string? OffloadingPort { get; set; }
public string? ContainerReceived { get; set; }
public string? NoOfFlatcases { get; set; }
public string? Voyage { get; set; }
public string? MBLNumber { get; set; }
public string? RedirectToSACD { get; set; }
public bool IsUpdate { get; set; }
public string? ErrorMessage { get; set; }
public bool HasErrors => !string.IsNullOrEmpty(ErrorMessage);
public string StatusClass => Status switch
{
"Pending" => "table-warning",
"Validated" => "table-success",
"Imported" => "table-info",
"Error" => "table-danger",
_ => "table-secondary"
};
}
///
/// View model for import execution
///
public class ImportExecutionViewModel
{
public Guid SessionId { get; set; }
public string FileName { get; set; } = string.Empty;
public int TotalRecords { get; set; }
public int ValidRecords { get; set; }
public string ImportMode { get; set; } = string.Empty;
public bool IsExecuting { get; set; }
public ImportProgressViewModel? Progress { get; set; }
public ImportResultViewModel? Result { get; set; }
}
///
/// View model for import progress
///
public class ImportProgressViewModel
{
public int CurrentRecord { get; set; }
public int TotalRecords { get; set; }
public string CurrentOperation { get; set; } = string.Empty;
public decimal PercentageComplete { get; set; }
public string ProgressBarClass => PercentageComplete switch
{
>= 100 => "bg-success",
>= 75 => "bg-info",
>= 50 => "bg-warning",
>= 25 => "bg-primary",
_ => "bg-secondary"
};
}
///
/// View model for import result
///
public class ImportResultViewModel
{
public bool IsSuccess { get; set; }
public string Message { get; set; } = string.Empty;
public int RecordsProcessed { get; set; }
public int RecordsSkipped { get; set; }
public int RecordsFailed { get; set; }
public List Errors { get; set; } = new List();
public TimeSpan ProcessingTime { get; set; }
public string ResultClass => IsSuccess ? "alert-success" : "alert-danger";
public string ResultIcon => IsSuccess ? "â" : "â";
}
///
/// View model for import history
///
public class ImportHistoryViewModel
{
public List RecentSessions { get; set; } = new List();
public int TotalSessions { get; set; }
public int SuccessfulSessions { get; set; }
public int FailedSessions { get; set; }
public decimal OverallSuccessRate { get; set; }
public bool HasSessions => RecentSessions.Count > 0;
}
///
/// View model for import error details
///
public class ImportErrorViewModel
{
public long Id { get; set; }
public string ErrorType { get; set; } = string.Empty;
public string ErrorMessage { get; set; } = string.Empty;
public string? ErrorDetails { get; set; }
public int? RowNumber { get; set; }
public string? FieldName { get; set; }
public string Severity { get; set; } = string.Empty;
public DateTime CreatedAt { get; set; }
public string SeverityClass => Severity switch
{
"Critical" => "text-danger fw-bold",
"Error" => "text-danger",
"Warning" => "text-warning",
"Info" => "text-info",
_ => "text-secondary"
};
public string SeverityIcon => Severity switch
{
"Critical" => "đ¨",
"Error" => "â",
"Warning" => "â ī¸",
"Info" => "âšī¸",
_ => "âĸ"
};
}
}