using Exam.Infrastructure.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Hotline.Application.Exam.Core.Utilities
{
    public static class CodeUtility
    {
        public static string GenerateCode(string codePrefix, int length, string code)
        {
            var number = string.Empty;

            number = code.IsNotNullOrEmpty() ? code.Substring(code.Length - length, length) : "0";

            var value = int.Parse(number) + 1;

            code = $"{codePrefix}{DateTime.Now.ToString("yyyyMMdd")}{value.ToString().PadLeft(length, '0')}";

            return code;
        }
    }
}
