public IActionResult Delete(SocketDeleteViewModel model) { List <TimeTask> timeTasks = _timeTaskRepository.TimeTasks .Include(tt => tt.Socket) .Where(tt => tt.Socket.SocketId == model.SocketId) .ToList(); foreach (TimeTask timeTask in timeTasks) { BackgroundJob.Delete(timeTask.BackgroundJobId); } _socketRepository.DeleteSocket(model.SocketId); _socketRepository.Savechanges(); return(RedirectToAction("Index", "Socket")); }
public async Task <IActionResult> Delete(int id) { Socket socket = _socketRepository.GetSocketById(id); if (socket == null) { return(new NotFoundResult()); } AuthorizationResult authorizationResult = await _authorizationService .AuthorizeAsync(User, socket, Operations.Delete); if (!authorizationResult.Succeeded) { return(new ForbidResult()); } SocketDeleteViewModel socketViewModel = _mapper.Map <SocketDeleteViewModel>(socket); return(View(socketViewModel)); }