public async Task <JsonResult> DeleteTicket(int?id)
        {
            if (id != null)
            {
                Ticket ticket = await db.Tickets.Include(z => z.ParentTicket).Include(z => z.User).SingleOrDefaultAsync(x => x.Id == id);

                User curUser = await userManager.GetCurrentUser();

                TeamPermissions teamPerms = await GetCurrentTeamPermissions(ticket.TeamId, curUser.Id);

                if (ticket != null && teamPerms != null)
                {
                    if (ticket.User.Id == curUser.Id || curUser.AppRole.Permissions.IsAdmin || teamPerms.CanDeleteTickets)
                    {
                        await ticketManager.Delete(id, curUser);

                        return(Json(true, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            return(Json(false, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Delete(string id)
        {
            await _manager.Delete(new Guid(id));

            return(Ok(id));
        }