コード例 #1
0
        public async Task <JsonResult> OnPostDeleteAsync(int id)
        {
            User.HasRequiredClaims(new List <string> {
                MasterPermissions.Delete, ProductPermissions.Delete
            });
            var thisProduct = await Mediator.Send(new DeleteProductByIdCommand { Id = id });

            Notify.AddInfoToastMessage($"Product with Id {id} Deleted.");
            var response = await Mediator.Send(new GetAllProductsQuery());

            if (response.Succeeded)
            {
                var data = response.Data;
                Products = Mapper.Map <IEnumerable <ProductViewModel> >(data);
            }
            var html = await Renderer.RenderPartialToStringAsync("_ViewAll", Products);

            return(new JsonResult(new { isValid = true, html = html }));
        }