using AsbCloudApp.Data.AutogeneratedDailyReport;
using ClosedXML.Excel;

namespace AsbCloudInfrastructure.Services.AutoGeneratedDailyReports.AutogeneratedDailyReportBlocks;

public class HeadExcelBlockWriter : IExcelBlockWriter
{
	private static readonly (int, int) customerCell = (2, 2);
	private static readonly (int, int) depositCell = (4, 2);
	private static readonly (int, int) clusterCell = (5, 2);
	private static readonly (int, int) wellCell = (6, 2);

	private const int dateRow = 9;
	private const int dateFromColumn = 2;
	private const int dateFromToColumn = 3;

	private const int depthRow = 10;
	private const int depthFromColumn = 2;
	private const int depthToColumn = 3;
	
	public void Write(IXLWorksheet sheet, AutoGeneratedDailyReportDto report)
	{
		sheet.Cell(customerCell.Item1, customerCell.Item2).Value = report.Head.Customer;
		sheet.Cell(depositCell.Item1, depositCell.Item2).Value = report.Head.Deposit;
		sheet.Cell(clusterCell.Item1, clusterCell.Item2).Value = report.Head.Cluster;
		sheet.Cell(wellCell.Item1, wellCell.Item2).Value = report.Head.Well;

		sheet.Cell(dateRow, dateFromColumn).Value = report.ReportDate;
		sheet.Cell(dateRow, dateFromToColumn).Value = report.ReportDate.AddDays(1);

		sheet.Cell(depthRow, depthFromColumn).Value = report.Head.DepthFrom;
		sheet.Cell(depthRow, depthToColumn).Value = report.Head.DepthTo;
	}
}