Я хочу ввести случайную дату для данного класса в заметке при прохождении заметки из блока текста. Как можно ввести и добавить случайную дату для данного текста заметки?
using CY.Data.Interface;
using CY.Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CY.Data.Ado
{
public class NoteRepository : INoteRepository
{
.....
public static void RandomDate()
{
// 1. Adding the Start Date for the number of time that it is going to start.
// 2. Adding the End Date for the time it is going to end.
// 3. Adding the range of the time for the total number of days.
// 4. Add a int randDays where one converts the rnd.Next to in a Int32 numRange format.
// 5. Print a Random Random on a console writeline input.
DateTime startDate = DateTime.Now.AddYears(-1);
DateTime endDate = DateTime.Now;
double numRange = (endDate - startDate).TotalDays;
int randDays = rnd.Next(Convert.ToInt32(numRange));
DateTime randDate = startDate.AddDays(randDays);
Console.WriteLine(randDate.ToString());
}
}
}
Конечный результат должен использовать случайную дату и запускать ее в браузере. Как использовать ADO.NET для интеграции печати случайной даты на данной заметке?
Ссылки:
1) Документация Microsoft по ADO.NET: https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/ado-net-overview
2) Документация Microsoftоб использовании наборов данных из ADO.NET для печати данных: https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/ado-net-datasets