Ejemplo n.º 1
0
        public async Task <Unit> Handle(DeleteGroupCommand request, CancellationToken cancellationToken)
        {
            var group = await _genericRepository.GetByIdAsync(request.GroupId);

            if (group == null)
            {
                throw new NotFoundException(nameof(Card), request.GroupId);
            }

            await _genericRepository.DeleteAsync(request.GroupId);

            _genericRepository.SaveChanges();

            return(Unit.Value);
        }
Ejemplo n.º 2
0
        public virtual async Task <IActionResult> Delete(int id, string grid)
        {
            if (!OnDeleteAuthCheck())
            {
                return(new ForbidResult());
            }
            try
            {
                var item = await GetDeleteItem(id);

                if (item == null)
                {
                    return(new JavascriptResult(StringExt.JsAlert(UI.NotFound)));
                }
                DeleteGoBackUrl = Url.Action("Index");
                if (OnDeleteCheck(item))
                {
                    if (await Repo.DeleteAsync(item))
                    {
                        OnAfterDelete(id);
                        if (!grid.IsEmpty())
                        {
                            if (grid == "goback")
                            {
                                return(new JavascriptResult($"Goto('{DeleteGoBackUrl}')"));
                            }
                            else
                            {
                                return(new JavascriptResult(string.Format(DeleteJsAction2, grid)));
                            }
                        }
                        else
                        {
                            return(new JavascriptResult(DeleteJsAction));
                        }
                    }
                    return(new JavascriptResult(StringExt.JsAlert(MvcLogger.GetErrorMessage(ModelState))));
                }
                return(new JavascriptResult(StringExt.JsAlert(UI.NoAccess)));
            }
            catch (Exception ex)
            {
                return(new JavascriptResult(StringExt.JsAlert(MvcLogger.GetErrorMessage(ex))));
            }
        }
Ejemplo n.º 3
0
 public async Task <T> DeleteAsync(int id)
 {
     return(await _GenericRepositoryAsync.DeleteAsync(id));
 }