| | | 1 | | using Syki.Back.Domain.Enums; |
| | | 2 | | |
| | | 3 | | namespace Syki.Back.Commands.Domain.Commands; |
| | | 4 | | |
| | | 5 | | public class CommandBatch |
| | | 6 | | { |
| | 0 | 7 | | public int Id { get; set; } |
| | 0 | 8 | | public int InstitutionId { get; set; } |
| | 0 | 9 | | public CommandBatchType Type { get; set; } |
| | 0 | 10 | | public CommandBatchStatus Status { get; set; } |
| | 0 | 11 | | public DateTime CreatedAt { get; set; } |
| | 0 | 12 | | public DateTime? ProcessedAt { get; set; } |
| | | 13 | | |
| | | 14 | | /// <summary> |
| | | 15 | | /// Id do comando que gerou o lote |
| | | 16 | | /// </summary> |
| | 0 | 17 | | public int? SourceCommandId { get; set; } |
| | | 18 | | |
| | | 19 | | /// <summary> |
| | | 20 | | /// Id do comando que será executado quando o lote for processado com sucesso |
| | | 21 | | /// </summary> |
| | 0 | 22 | | public int? NextCommandId { get; set; } |
| | | 23 | | |
| | 0 | 24 | | public int Size { get; set; } |
| | | 25 | | |
| | 0 | 26 | | private CommandBatch() { } |
| | | 27 | | |
| | | 28 | | public static CommandBatch New( |
| | | 29 | | int institutionId, |
| | | 30 | | CommandBatchType type, |
| | | 31 | | int? sourceCommandId = null) |
| | | 32 | | { |
| | 0 | 33 | | return new() |
| | 0 | 34 | | { |
| | 0 | 35 | | Type = type, |
| | 0 | 36 | | CreatedAt = DateTime.UtcNow, |
| | 0 | 37 | | InstitutionId = institutionId, |
| | 0 | 38 | | Status = CommandBatchStatus.Pending, |
| | 0 | 39 | | SourceCommandId = sourceCommandId, |
| | 0 | 40 | | }; |
| | | 41 | | } |
| | | 42 | | |
| | | 43 | | public void ContinueWith(Command command) |
| | | 44 | | { |
| | 0 | 45 | | NextCommandId = command.Id; |
| | 0 | 46 | | command.SetAwaiting(); |
| | 0 | 47 | | } |
| | | 48 | | } |