using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MMBLL.Item; using static GB5Shared.GB5Constant.Constant; namespace MMSL.EndPoints.Item { // GB4 migration: DELETE /mms/Item.svc/?ItemId={ItemId} // IItem.cs → [OperationContract(Name = "DeleteItem")] ResponseStandardDTO Delete(int ItemId) // Item.svc.cs → Delete(int ItemId) → PooledItemBLL.DeleteItem(ItemId, LoginDTO) // // GB4's Delete also called AuthorizationFrameBLL.CheckUserRights(MMS_ITEM_DELETE, ..., DELETE). // GB5's equivalent is the [MenuRights(menuCode, RightOperation.Delete)] attribute, which is // opt-in per endpoint and keyed on a menu code from uscdevsys. No MM endpoint carries it yet, // so this endpoint follows the module's current AllowAnonymous convention; add the attribute // here once the Item menu code is confirmed. public class DeleteItem : BaseEndpoint> { private readonly IItemBLL _ItemBLL; public DeleteItem(IItemBLL ItemBLL) { _ItemBLL = ItemBLL; } public override void Configure() { Delete("/Item/DeleteItem"); AllowAnonymous(); } public record DeleteItemParameters( [property: FromHeader] string Login, [property: QueryParam] int ItemId ); protected override async Task> ExecuteAsync(DeleteItemParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _ItemBLL.DeleteItem(req.ItemId, LoginDTO!, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.NOT_REQUIRED, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, LoginDTO, ex.Message, 500); } } } }