public ActionResult DeleteVolunteer(int id) { try { var result = _volunteerService.Delete(id); var result2 = _userService.Delete(id); var assign = _assignedRequest.GetVoluenteerAll(id); foreach (var p in assign.Data) { _assignedRequest.Delete(p.AssignedId); } var workShop = _assignworkShopService.GetAllByUserId(id); foreach (var p in workShop.Data) { _assignworkShopService.Delete(p.AssignWorkShopId); } var notification = _notificationService.GetAllByUserId(id); foreach (var p in notification.Data) { _notificationService.Delete(p.NotificationId); } return(RedirectToAction("GetAllVolunteer")); } catch (Exception e) { return(Content(e.Message)); } }
public IActionResult Delete(Guid Id) { Volunteer deletedVolunteer = _volunteerService.Delete(Id); if (deletedVolunteer != null) { TempData["message"] = $"{deletedVolunteer.LastName} was deleted"; } return(Redirect("Index")); }
public IActionResult Delete(string id) { _logger.LogInformation($"Trying to delete volunteer record {id}"); try { var exists = _volunteersService.Get(id); VolunteersResponse.Success = false; VolunteersResponse.Data = new List <Volunteer>(); if (exists == null) { VolunteersResponse.Message = "Volunteer record not found. Cannot delete."; return(NotFound(new[] { VolunteersResponse })); } bool volunteerRemoved = _volunteersService.Delete(id); if (!volunteerRemoved) { VolunteersResponse.Message = "Volunteer record not deleted"; return(BadRequest(new[] { VolunteersResponse })); } VolunteersResponse.Success = true; VolunteersResponse.Message = $"Volunteer record with id {id} deleted."; return(Ok(new[] { VolunteersResponse })); } catch (MongoException ex) { _logger.LogDebug($"Error removing from DB: {ex.Message}"); } catch (Exception ex) { _logger.LogDebug($"Error: {ex.Message}"); } _logger.LogInformation("Error: delete request cannot be handled, bad request."); return(BadRequest()); }
public void Delete(long id) { _volunteerService.Delete(id); }
public void Delete([FromBody] long id) { volunteerService.Delete(id); }
public void Delete(long id) { _uow.BeginTransaction(); _volunteerService.Delete(id); _uow.Commit(); }