public async Task <ActionResult> GetProtocol(int protocolId) { var protocol = await _protocolsService.GetProtocolByIdAsync(protocolId); if (protocol == null) { return(NotFound()); } if (protocol.DepartmentId != DepartmentId) { return(Unauthorized()); } var result = ProtocolResult.Convert(protocol); return(Ok(JsonConvert.SerializeObject(result))); }
public async Task <bool> CanUserModifyProtocolAsync(string userId, int protocolId) { var department = await _departmentsService.GetDepartmentByUserIdAsync(userId); var protocol = await _protocolsService.GetProtocolByIdAsync(protocolId); if (department == null || protocol == null) { return(false); } if (protocol.DepartmentId != department.DepartmentId) { return(false); } if (department.IsUserAnAdmin(userId)) { return(true); } return(false); }
public async Task <IActionResult> GetProtocol(int id) { var template = await _protocolsService.GetProtocolByIdAsync(id); return(Json(template)); }