@inject IUnitOfWork _unit
@inject IDialogService DialogService
@inject ISnackbar Snackbar
<div class="d-flex flex-column flex-grow-1 gap-2">
<MudCard Class="" Elevation="2">
<MudCardHeader Class="d-flex justify-space-between flex-grow-1 gap-4">
<MudText Typo="Typo.h4">Quản lý Magazine</MudText>
<div class="d-flex flex-row-reverse flex-grow-1 gap-4">
<MudButton OnClick="ClearAllMgz" Variant="Variant.Filled" EndIcon="@Icons.Material.Filled.ClearAll" Color="Color.Error">Clear All Magazines</MudButton>
<MudDivider DividerType="DividerType.Middle" Style="height: 2px" />
<MudGrid Justify="Justify.SpaceBetween">
<MudTextField @bind-Value="SearchMgzId" Label="Mã magazine" Variant="Variant.Text"></MudTextField>
<MudTextField @bind-Value="SearchMgzTracking" Label="Trạng thái Magazine" Variant="Variant.Text"></MudTextField>
<MudTextField @bind-Value="SearchMgzIdSlip" Label="Id Matching" Variant="Variant.Text"></MudTextField>
<MudText>Đã tìm được: <b>@SearchCountResult</b> kết quả</MudText>
<MudButton Variant="Variant.Filled" EndIcon="@Icons.Material.Filled.Search" Color="Color.Primary" OnClick="MgzSearchClick">Tìm kiếm</MudButton>
<MudTable T="MagazineViewDTO" Items="@MgzSearchList" Dense="true" Hover="true" Bordered="false" Striped="false" SortLabel="Sort By"
Virtualize="true" FixedHeader="true">
<MudTh><MudTableSortLabel Class="d-flex justify-center flex-grow-1" Style="text-align:center;" SortBy="new Func<MagazineViewDTO, object>(x=>x.MagazineCode)">Mã Magazine</MudTableSortLabel></MudTh>
<MudTh><MudTableSortLabel Class="d-flex justify-center flex-grow-1" Style="text-align:center;" SortBy="new Func<MagazineViewDTO, object>(x=>x.DepartureTime)">Thời gian khởi hành</MudTableSortLabel></MudTh>
<MudTh><MudTableSortLabel Class="d-flex justify-center flex-grow-1" Style="text-align:center;" SortBy="new Func<MagazineViewDTO, object>(x=>x.CreateAt)">Thời gian tạo</MudTableSortLabel></MudTh>
<MudTh><MudTableSortLabel Class="d-flex justify-center flex-grow-1" Style="text-align:center;" SortBy="new Func<MagazineViewDTO, object>(x=>x.ModifiedAt)">Thời gian chỉnh sửa</MudTableSortLabel></MudTh>
<MudTh><MudTableSortLabel Class="d-flex justify-center flex-grow-1" Style="text-align:cen`ter;" SortBy="new Func<MagazineViewDTO, object>(x=>x.MgzTrackingText)">Trạng thái Magazine</MudTableSortLabel></MudTh>
<MudTh><MudTableSortLabel Class="d-flex justify-center flex-grow-1" Style="text-align:center;" SortBy="new Func<MagazineViewDTO, object>(x=>x.IdMatching)">Mã Matching</MudTableSortLabel></MudTh>
<MudTh><MudTableSortLabel Class="d-flex justify-center flex-grow-1" Style="text-align:center;" SortBy="new Func<MagazineViewDTO, object>(x=>x.Site)">Site</MudTableSortLabel></MudTh>
<MudTd Style="text-align:center;" DataLabel="Loại NV">@context.MagazineCode </MudTd>
<MudTd Style="text-align:center;" DataLabel="IP Buffer">@context.DepartureTime.ToString("dd/MM/yyyy HH:mm") </MudTd>
<MudTd Style="text-align:center;" DataLabel="Mã vị trí">@context.CreateAt.ToString("dd/MM/yyyy HH:mm") </MudTd>
<MudTd Style="text-align:center;" DataLabel="Capa Buffer">@context.ModifiedAt.ToString("dd/MM/yyyy HH:mm") </MudTd>
<MudTd Style="text-align:center;" DataLabel="IdSlip">@context.MgzTrackingText </MudTd>
<MudTd Style="text-align:center;" DataLabel="Mã vị trí">@context.IdMatching </MudTd>
<MudTd Style="text-align:center;" DataLabel="Site">@context.Site </MudTd>
<div class="d-flex flex-row gap-1 justify-content-end">
<MudIconButton Color="@Color.Error" Variant="Variant.Filled" Icon="@Icons.Material.Filled.Delete" OnClick="@(() => DeleteMgzClick(@context))"></MudIconButton>
<MudTablePager PageSizeOptions="new int[]{ 100, 200, 500}" />
<MudOverlay Visible="LoadDataActive" DarkBackground="true" ZIndex="9999" AutoClose="false">
<MudProgressCircular Color="Color.Primary" Style="height:70px;width:70px;" Indeterminate="true" />
private bool LoadDataActive = false;
private string SearchMgzId = "";
private int SearchMgzTracking = 69;
private long SearchMgzIdSlip = 69;
private int SearchCountResult = 0;
private List<MagazineViewDTO> MgzSearchList = new List<MagazineViewDTO>();
protected override void OnInitialized()
private async void MgzSearchClick()
MgzSearchList = await _unit.MaterialMgzes.GetAllMgzsAsync(SearchMgzId, SearchMgzTracking, SearchMgzIdSlip);
SearchCountResult = MgzSearchList.Count();
private async void DeleteMgzClick(MagazineViewDTO mgz)
var _mgz = await _unit.MaterialMgzes.FindFirstAsync(m => m.Id == mgz.MagazineId);
_unit.MaterialMgzes.Delete(_mgz);
var _hismgz = JsonConvert.DeserializeObject<MaterialMgzHisEntity>(JsonConvert.SerializeObject(_mgz));
_hismgz.Id = Guid.NewGuid();
_hismgz.Tracking = MagazineTracking.DELETED;
_hismgz.ModifiedAt = DateTime.Now;
await _unit.MaterialMgzHises.AddAsync(_hismgz);
await _unit.CompleteAsync();
Snackbar.Add("Đã xóa xong", Severity.Success);
MgzSearchList.Remove(mgz);
private bool ShowAddMission = false;
private bool ShowEditMgzActive = false;
private async Task ClearAllMgz()
var _mgzlist = await _unit.MaterialMgzes.GetAllAsync();
foreach (var _mgz in _mgzlist)
_unit.MaterialMgzes.Delete(_mgz);
await _unit.CompleteAsync();
Snackbar.Add($"Đã xóa hết Magazine", Severity.Success);