public async Task <IActionResult> Index(int id) { Socket socket = _socketRepository.GetSocketById(id); if (socket == null) { return(new NotFoundResult()); } TimeTask timeTask = new TimeTask { Socket = socket }; AuthorizationResult authorizationResult = await _authorizationService .AuthorizeAsync(User, timeTask, Operations.Read); if (!authorizationResult.Succeeded) { return(new ForbidResult()); } ViewData["SocketName"] = socket.Name; ViewData["RoomName"] = socket.Room.Name; IEnumerable <TimeTaskListViewModel> timeTaskViewModel = _mapper .Map <IEnumerable <TimeTask>, IEnumerable <TimeTaskListViewModel> >(socket.TimeTasks.OrderBy(tt => tt.TimeStamp).ToList()); return(View(timeTaskViewModel)); }
public async Task <IActionResult> Edit(int id) { Socket socket = _socketRepository.GetSocketById(id); if (socket == null) { return(new NotFoundResult()); } AuthorizationResult authorizationResult = await _authorizationService .AuthorizeAsync(User, socket, Operations.Update); if (!authorizationResult.Succeeded) { return(new ForbidResult()); } SocketEditViewModel socketViewModel = _mapper.Map <SocketEditViewModel>(socket); socketViewModel.Rooms = GetRoomsSelectList(); return(View(socketViewModel)); }