public async Task <bool> DoDeleteWork(long currentUserId, Label label) { await _transactionalExecutor.ExecuteAsync <bool>(async connection => { _organizationRepository.SetSqlExecutorForTransaction(connection); _userRepository.SetSqlExecutorForTransaction(connection); _projectRepository.SetSqlExecutorForTransaction(connection); _labelRepository.SetSqlExecutorForTransaction(connection); await _labelRepository.Delete(currentUserId, label.Id); var organization = await _organizationRepository.SelectById(label.OrganizationId); organization.LabelCount--; await _organizationRepository.Update(currentUserId, organization); var project = await _projectRepository.SelectById(label.ProjectId); project.LabelCount--; await _projectRepository.Update(currentUserId, project); var user = await _userRepository.SelectById(currentUserId); user.LabelCount--; await _userRepository.Update(currentUserId, user); return(true); }); return(true); }
public async Task <IActionResult> DeleteConfirmed(int id) { //var label = await _context.Labels.FindAsync(id); // Original scaffold call using context directly var label = await _repository.GetById(id); //_context.Labels.Remove(label); // Original scaffold call using context directly await _repository.Delete(id); //await _context.SaveChangesAsync(); // Original scaffold call using context directly return(RedirectToAction(nameof(Index))); }
public async Task <ActionResult <Label> > DeleteLabel(int id) { //var label = await _context.Labels.FindAsync(id); // Original scaffold call using context directly var label = await _repository.GetById(id); if (label == null) { return(NotFound()); } //_context.Labels.Remove(label); // Original scaffold call using context directly await _repository.Delete(id); //await _context.SaveChangesAsync(); // Original scaffold call using context directly return(label); }
public async Task <ActionResult <string> > DeleteLabel(string labelid) { return(await lr.Delete(labelid, HttpContext.Items["UserID"].ToString())); }