public async Task <IActionResult> Delete(int contactId)
        {
            var affectedResult = await _contactsService.Delete(contactId);

            if (affectedResult == 0)
            {
                return(BadRequest());
            }
            return(Ok());
        }
Esempio n. 2
0
 public void Delete(int id)
 {
     try
     {
         var model = _contactsService.GetContact(id);
         _contactsService.Delete(model);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 3
0
        public ActionResult Delete(int id)
        {
            var result = _contactsService.Delete(id);

            if (result > 0)
            {
                return(Ok("Contact Successfully Deleted for ID: " + id));
            }
            else
            {
                return(NotFound("Contact Not Found for ID: " + id));
            }
        }
Esempio n. 4
0
 public IActionResult Delete(int id)
 {
     try
     {
         _contactService.Delete(id);
         return(Ok());
     }
     catch (ContactNotFoundException ex)
     {
         return(BadRequest(new { message = ex.Message }));
     }
     catch (ForbiddenException)
     {
         return(Forbid());
     }
 }
Esempio n. 5
0
 public ActionResult Delete(int id, ContactViewModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             contacts.Delete(id);
             ViewBag.Success = "";
             return(View());
         }
         catch (Exception ex)
         {
             return(View(ex.Message));
         }
     }
     else
     {
         ViewBag.Failed = "This action could not be completed. Try again!";
         return(View());
     }
 }
Esempio n. 6
0
 public async void Delete(int id)
 {
     await _contactsService.Delete(id);
 }
 public IActionResult Delete(Guid id)
 {
     _service.Delete(id);
     return(Ok());
 }
 public IActionResult Delete([FromBody] int id)
 {
     _contactsService.Delete(id);
     return(Ok());
 }
        public IActionResult Delete(ContactViewModel contactViewModel)
        {
            _contactsService.Delete(contactViewModel);

            return(RedirectToAction("Index"));
        }
 public Task Delete(int contactId) => _safeRunner.Run(() => _contactsService.Delete(contactId), Ok);