48 lines
1.6 KiB
C#
48 lines
1.6 KiB
C#
using PSTW_CentralSystem.Areas.Inventory.Models;
|
|
using System;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
namespace PSTW_CentralSystem.Areas.OTcalculate.Models
|
|
{
|
|
[Table("otregisters")]
|
|
public class OtRegisterModel
|
|
{
|
|
[Key]
|
|
public int OvertimeId { get; set; }
|
|
|
|
[Required]
|
|
public DateTime OtDate { get; set; }
|
|
|
|
public TimeSpan? OfficeFrom { get; set; }
|
|
public TimeSpan? OfficeTo { get; set; }
|
|
public int? OfficeBreak { get; set; }
|
|
public TimeSpan? OutsideFrom { get; set; }
|
|
public TimeSpan? OutsideTo { get; set; }
|
|
public int? OutsideBreak { get; set; }
|
|
public int? StationId { get; set; }
|
|
|
|
[ForeignKey("StationId")]
|
|
public virtual StationModel? Stations { get; set; }
|
|
|
|
public string OtDescription { get; set; }
|
|
public string OtDays { get; set; }
|
|
public required string PDFBase64 { get; set; }
|
|
public required string IvBase64 { get; set; }
|
|
|
|
[Required]
|
|
public int UserId { get; set; }
|
|
|
|
// Convert string times to TimeSpan before saving
|
|
public TimeSpan? GetOfficeFrom() => ParseTimeSpan(OfficeFrom?.ToString());
|
|
public TimeSpan? GetOfficeTo() => ParseTimeSpan(OfficeTo?.ToString());
|
|
public TimeSpan? GetOutsideFrom() => ParseTimeSpan(OutsideFrom?.ToString());
|
|
public TimeSpan? GetOutsideTo() => ParseTimeSpan(OutsideTo?.ToString());
|
|
|
|
private TimeSpan? ParseTimeSpan(string? time)
|
|
{
|
|
return TimeSpan.TryParse(time, out TimeSpan result) ? result : null;
|
|
}
|
|
}
|
|
}
|