public async Task <IActionResult> DeleteHeaAgents([FromRoute] int id) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await _repository.Delete(id); return(Ok("Deleted")); }
public AgentsViewModel(IAgentRepository agentRepo, IViewModelFactory vmFactory, IUserInteraction ui) { _agentRepo = agentRepo; _vmFactory = vmFactory; var agentVms = agentRepo.GetAll().Select(x => CreateAgentViewModel(x)); Agents.ReplaceItems(agentVms); AddAgentCommand = new ActionCommand(o => { Agents.Add(CreateAgentViewModel(null)); IsDirty = true; }); DeleteAgentCommand = new ActionCommand(_ => { var selectedAgent = Agents.FirstOrDefault(x => x.IsSelected); if (selectedAgent == null) { ui.ShowWarning("No agent selected."); return; } if (!ui.AskForConfirmation($"Are you sure you want to delete the selected '{selectedAgent.Id}' agent?", "Delete agent")) { return; } Agents.Remove(selectedAgent); if (!string.IsNullOrEmpty(selectedAgent.Id)) { agentRepo.Delete(selectedAgent.Id); } }); CommitAgentsCommand = new ActionCommand(_ => CommitAgents(), _ => IsDirty && !HasErrors); ResetChangesCommand = new ActionCommand(_ => { foreach (var agent in Agents) { agent.ResetForm(); } IsDirty = false; }, _ => IsDirty); PropertiesAreInitialized = true; }
public IActionResult DeleteAlias(int id) { if (!_agentRepo.Get(id).Success) { return(NotFound($"Alias {id} not found")); } var result = _agentRepo.Delete(id); if (result.Success) { return(Ok()); } else { return(BadRequest(result.Messages)); } }
public IActionResult Delete(int id) { var getAgentResult = agentRepository.Get(id); if (!getAgentResult.Success) { return(NotFound($"Agent {id} not found")); } var response = agentRepository.Delete(id); if (response.Success) { return(Ok()); } else { return(BadRequest(response.Message)); } }
public void Delete(int id) { _agentRepository.Delete(id); }