Beispiel #1
0
 public ActionResult <String> Delete(int id)
 {
     try
     {
         var userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
         return(Ok(_cs.Delete(id, userId)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
 private void BtnCardsDelete_Click(object sender, EventArgs e)
 {
     if (lbCards.SelectedItem != null)
     {
         if (FlashcardsMessageBox.YesNo("Are you sure to delete card?"))
         {
             var category = (lbCategories.SelectedItem as Category)?.Name;
             var deck     = (lbDecks.SelectedItem as Deck)?.Name;
             _cardsService.Delete(_topic, category, deck, ((Card)lbCards.SelectedItem).Id);
             RefreshCards(category, deck);
         }
     }
 }
    public object Delete(int id)
    {
        Dictionary <string, object> retorno = new Dictionary <string, object>();

        try
        {
            service.Delete(id);
            retorno.Add("success", true);
            return(Request.CreateResponse(HttpStatusCode.OK, retorno));
        }
        catch (Exception)
        {
            retorno.Add("success", false);
            return(Request.CreateResponse(HttpStatusCode.InternalServerError, retorno));
        }
    }